O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

GetObject Function

Syntax

GetObject([pathname] [, class])
pathname

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.

class

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.

Description

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required