GetObject Function


GetObject([pathname] [, class])

Use: Optional

Data Type: String

The full path and filename of a file that stores the state of an automation object, or a moniker (that is, a name that represents an object) along with the information required by the syntax of the moniker to identify a specific object.


Use: Optional

Data Type: String

The object’s programmatic identifier (ProgID), as defined in the system registry.

Return Value

A reference to an ActiveX object.


Returns a reference to an automation object. The GetObject function has three functions:

  • It retrieves references to objects from the Running Object Table.

  • It loads persisted state into objects.

  • It creates objects based on monikers.

Rules at a Glance

  • Although both pathname and class are optional, at least one argument must be supplied.

  • GetObject can be used to retrieve a reference to an existing instance of an automation object from the Running Object Table. For this purpose, you supply the object’s programmatic identifier as the class argument. However, if the object cannot be found in The Running Object Table, GetObject is unable to create it and instead returns runtime error 429, “ActiveX component can’t create object.” To create a new object instance, use the CreateObject function.

  • If you specify a class argument and specify pathname as a zero-length string, GetObject returns a new instance of the object—unless the object is registered as single instance, in which case the current instance ...

Get VBScript in a Nutshell, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.