GETOBJECT( ) Function

Activates an Automation object and creates a reference to the object.

GETOBJECT(cFileName | Moniker [, cClassName])



Specifies the full path and name of the file to activate. The application does not need to be specified, because the OLE dynamic link libraries determine the application to start based on the file name you provide.

For example, the following code launches Microsoft Excel, opens a file named BUDGET.XLS, and creates a reference through an object variable named MBUDVAR:

 CopyCode imageCopy Code

The identifier of a COM object that implements the IMoniker interface. A moniker can be any of the following types: file, item, generic composite, anti-, pointer, and URL. For details about COM monikers, search for "IMoniker" on the Microsoft Developer Network.


Specifies the class name of the object to retrieve. Some applications can store more than one object type in the same file, making it possible for you to use the class name to specify the object to activate. For example, if a word processing application stores its documents, macro definitions, and ToolBar objects in the same file, you can create a reference to the document file with the following command:

 CopyCode imageCopy Code

With some server applications, each time you issue GETOBJECT( ), an additional instance of the application is started, using additional memory. If the application is already running, you can prevent additional instances of the application from starting by omitting FileName and including ClassName, as in this example:

 CopyCode imageCopy Code
oleApp = GETOBJECT(, "Excel.Application")

Expand imageReturns

Expand imageRemarks

Expand imageExample

Expand imageSee Also

© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic