ContentsIndexPreviousNext

6.10.12 Creating OLE Objects That are Not Controls

ACUCOBOL-GT supports a new verb to accommodate OLE objects that are not controls: CREATE. The CREATE statement creates a new instance of an OLE object. Use it specifically for OLE objects that are not ActiveX controls. Use the SCREEN SECTION or Format 14 DISPLAY to create an instance of an ActiveX control. Refer to section 6.6 of Book 3, "Reference Manual" for syntax and general rules of this statement.

Every application that supports Automation provides at least one type of object that is not a control. For example, a word-processing application may provide an Application object, a Document object, and a Toolbar object. You can create an object on a remote-networked computer by passing the name of the computer in SERVER-NAME. That name is the same as the machine-name portion of a share name: For example, for a share named "\\MyServer\Public," server name is "MyServer."

The following code returns the version number of an instance of Excel running on a remote computer named MyServer:

CREATE Application of Excel
    SERVER-NAME is "MyServer"
    HANDLE in xl-app.
INQUIRE xl-app Version in xl-vers.
DISPLAY xl-vers.

If the remote server does not exist or is unavailable, then an exception is raised and xl-app will be set to NULL.

You might think of using CREATE if you want to use an ActiveX object that does not have a user interface. However, the CREATE verb will not create ActiveX objects. If you want to create an ActiveX object that does not have a visual representation on the screen, set VISIBLE = 0 in the DISPLAYstatement or screen section item. If you do not want any screen at all, create the initial window also with VISIBLE = 0.