Option 3: Connect to or instantiate a named Automation object and file
This option creates a connection to a new or existing instance of the specified Automation object and opens the specified file. If the file is not already open, it is opened. If the pathname for the specified file is invalid or unrecognizable by the Server, this connection option fails. In this example, the file \WorkSheets\Xplan.xls is opened in the new or existing instance of the "Excel.Sheet" object:
DEFINE VARIABLE hExcelObject AS COM-HANDLE NO-UNDO.
CREATE "Excel.Sheet" hExcelObject CONNECT TO "\WorkSheets\Xplan.xls".
The following figure summarizes the basic logic for this option (ignoring the listed error conditions).
Figure 56. Automation connection option 3
Note: This option is equivalent to the Visual Basic GetObject(pathname,class) function call.