COM_CreateObject

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > COM >

COM_CreateObject

 

Description

 

Creates a reference to a COM Server application.

 

Syntax

 

pIDispatch = COM_CreateObject(sServerName [, ErrorVar])

 

Returns

 

A DWord pointer to IDispatch

 

Parameters

 

Name

Type

Optional

Meaning

sServerName

String

No

Name of the COM server to create

ErrorVar

Variable

Yes

Must be a LONG variables passed by reference. If present it will be filled with an error code if an error occurs

 

Remarks

 

Restrictions

 

See also

 

Examples

 

USES "COM"

 

Dim pXlApp    As DWORD

Dim RetVal    As LONG

 

'---Try to create an Excel application reference

pXlApp = COM_CreateObject("Excel.Application", RetVal)

 

'---Do something ...

 

'--- Time to release the allocated interface objects

If ISFALSE(COM_Succeeded(COM_Release(pXlSheet))) Then

  MSGBOX 0, "ActiveSheet release fails"

End If