Extending product function with VBA : Automation and System Architect : Automation : Creating an instance of the application
  
Creating an instance of the application
Although the required applications are referenced by Microsoft VBA, it is not until code is written that the application objects can be controlled. This section describes how to set up a new instance of an application to access its automated objects and how to declare it.
An instance is a session of the required application. To use automation objects the application must be resident in memory (but does not have to be visible). To access objects, Microsoft VBA uses the Dim and Set statements to declare the instance of an automation object just like a declaration would be made to a built in type. The only difference with automation is that at the point the objects are to be used, a new instance of the object must be created with the Set statement.
The following code declares the variable ExObj as an Excel application:
Dim ExObj as Excel.Application
Note the full server.class name of the declaration: this ensures that the application class referred to is Excel’s. Other applications may also have classes called application.
The following line creates a new instance of the Excel application and also sets the point in the code that the instantiation takes place:
Set ExObj = New Excel.Application
The variable ExObj can now access the Excel automation objects, for example displaying the standard Open dialog box from Excel using the automation object GetOpenFilename() filtered for text files with the following code:
fileToOpen = ExObj.GetOpenFilename("Text Files (*.txt), *.txt")
So all of Excel’s Automation Objects are available alongside all of System Architect’s.
See also
Automation