xHarbour Reference Documentation > Function Reference |
Retturns an instantiated OLE Automation object.
GetActiveObject( <cProgID> ) --> oOleAuto
cProgID := "Word.Application" // MS Office Word cProgID := "Excel.Application" // MS Office Excel cProgID := "InternetExplorer.Application" // Internet Explorer
The function returns the TOleAuto object of an existing OLE automation instance. When the the requested OLE automation object is not running, a runtime error is raised.
The function GetActiveObject() is similar to CreateObject(). Hower, it searches a running instance of the desired OLE application, rather than loading a new instance into memory.
See also: | CreateObject() |
Category: | OLE Automation , xHarbour extensions |
Source: | rtl\win32ole.prg |
LIB: | xhb.lib, ole.lib |
DLL: | xhbdll.dll |
// The example shows the typyical programming pattern to request a running // OLE application. GetActiveObject() first requests an instantiated OLE // object. When this fails, the CreateObject() functions tries to instantiate // the OLE application. If this fails again, the requested OLE object is not // (properly) installed on the computer and the xHarbour application quits. PROCEDURE Main LOCAL oOLE TRY oOLE := GetActiveObject( "InternetExplorer.Application" ) CATCH TRY oOLE := CreateObject( "InternetExplorer.Application" ) CATCH Alert( "ERROR! IE not avialable. [" + Ole2TxtError()+ "]" ) QUIT END END <... code for OLE automation ...> oOle:quit() RETURN
http://www.xHarbour.com