Option 4: Connect to or instantiate implied Automation object and file
This option creates a connection to a new or existing instance of the Automation object implicitly defined by the specified file. This option identifies the Automation object and its Server from the specified filename extension, as defined in the registry. If the file is not already open in the Automation Object, it will be opened. In this example, the .xls extension indicates that the object instance is a Sheet object provided by the Excel Automation Server:
DEFINE VARIABLE hExcelObject AS COM-HANDLE NO-UNDO.
CREATE "" hExcelObject CONNECT TO "\WorkSheets\Xplan.xls".
The following figure summarizes the basic logic for this option (ignoring the listed error conditions).
Figure 57. Automation connection option 4
Note: This option is equivalent to the Visual Basic GetObject(pathname) function call.