Access GetObject function

Syntax
GetObject([ pathname ], [ class ])

The GetObject function syntax has these named arguments:

Code Examples
Use the GetObject function to access an ActiveX object from a file and assign the object to an object variable. Use the Set statement to assign the object returned by GetObject to the object variable. For example:

When this code is executed, the application associated with the specified pathname is started, and the object in the specified file is activated. If pathname is a zero-length string (""), GetObject returns a new object instance of the specified type. If the pathname argument is omitted, GetObject returns a currently active object of the specified type. If no object of the specified type exists, an error occurs. Some applications allow you to activate part of a file. Add an exclamation point (!) to the end of the file name and follow it with a string that identifies the part of the file that you want to activate. For information about how to create this string, see the documentation for the application that created the object. For example, in a drawing application you might have multiple layers to a drawing stored in a file. You could use the following code to activate a layer within a drawing called SCHEMA.CAD:

If you don't specify the object's class, automation determines the application to start and the object to activate, based on the file name you provide. Some files, however, may support more than one class of object. For example, a drawing might support three different types of objects: an Application object, a Drawing object, and a Toolbar object, all of which are part of the same file. To specify which object in a file you want to activate, use the optional class argument. For example:

In the example, FIGMENT is the name of a drawing application and DRAWING is one of the object types it supports. After an object is activated, you reference it in code by using the object variable you defined. In the preceding example, you access properties and methods of the new object by using the object variable MyObject. For example: