Name
GetObject Function
Syntax
GetObject([pathname
] [,class
])
-
pathname
Use: Optional
Data Subtype: String
The full path and name of the file containing the ActiveX object.
-
class
Use: Optional
Data Subtype: String
The class of the object (see next list).
The class
argument has these parts:
-
Appname
Use: Required
Data Subtype: String
The name of the application.
-
Objecttype
Use: Required
Data Subtype: String
The class of object to create, delimited from
Appname
by using a period (.
). For example,Appname.Objecttype
.
Return Value
Returns a reference to an ActiveX object.
Description
Accesses an ActiveX server held within a specified file and assigns a reference to it to an object variable.
Rules at a Glance
Although both
pathname
andclass
are optional, at least one parameter must be supplied.GetObject
is used when there is a current instance of the ActiveX object; to create the instance, use theCreateObject
function.If you 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 is returned.If you omit the pathname, the current instance of the object is returned.
An error is generated if
pathname
isn’t specified, and no current instance of the object can be found.To assign the reference returned by
GetObject
to your object variable, you must use theSet
statement:
Dim myObject Set myObject = GetObject("C:\OtherApp\Library.lib")
The details of how you create different objects and ...
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.