ComObjActive

Retrieves a registered COM object.

ComObj := ComObjActive(CLSID)

Parameters

CLSID

Type: String

CLSID or human-readable Prog ID of the COM object to retrieve.

Return Value

Type: ComObject

This function returns a new COM wrapper object with the variant type VT_DISPATCH (9).

Error Handling

An exception is thrown on failure.

ComValue, ComObject, ComObjGet, ComObjConnect, ComObjFlags, ObjAddRef/ObjRelease, ComObjQuery, GetActiveObject (Microsoft Docs)

Examples

Displays the active document in Microsoft Word, if it is running. For details about the COM object and its properties used below, see Word.Application object (Microsoft Docs).

word := ComObjActive("Word.Application")
if !word
    MsgBox "Word isn't open."
else
    MsgBox word.ActiveDocument.FullName