Creating Automation Objects

To create an Automation object in your VBA procedure, follow these steps:

■ Declare an object variable using the Dim.. .As Object or Dim.. .As Application.ObjectType clause (see the topics on using late and early binding in the preceding sections).

■ If you are using early binding, use the References dialog box to establish a reference to the application object type library.

■ If the Automation object doesn't exist yet, use the CreateObject function. If the Automation object already exists, establish the reference to the object by using the GetObject function.

■ Assign the object returned by the CreateObject or GetObject function to the object variable by using the Set keyword.

0 0

Post a comment