Skip to Main Content
VBScript in a Nutshell, 2nd Edition
book

VBScript in a Nutshell, 2nd Edition

by Paul Lomax, Matt Childs, Ron Petrusha
March 2003
Intermediate to advanced content levelIntermediate to advanced
512 pages
14h 30m
English
O'Reilly Media, Inc.
Content preview from VBScript in a Nutshell, 2nd Edition

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

VBScript in a Nutshell

VBScript in a Nutshell

Matt Childs, Paul Lomax, Ron Petrusha
Microsoft® PowerShell, VBScript and JScript® Bible

Microsoft® PowerShell, VBScript and JScript® Bible

William R. Stanek, James O'Neill, Jeffrey Rosen

Publisher Resources

ISBN: 0596004885Errata Page