Previous Topic: CA Gen as an OLE Automation ServerNext Topic: Name Work Views for Manipulating OLE Objects


Use an OLE Automation Object

The following steps explain how to use an OLE automation object:

  1. Dimension the object variable (create a work set in CA Gen).
  2. Create an object (use a set statement to set a work view).
  3. Set the object as the contents of the object variable (use a set statements to set a work view).
  4. Do the work you wish to do with the object (use the invoke method statements to work with the object).
  5. Clear the object when you are finished with it.

The next sample code illustrates an action diagram fragment that opens Microsoft Word and places the traveler's name into a field in a document.

1-    --- EVENT ACTION word open
2-   |    SET local guiobj word TO APPLICATION CreatObject(T:Word.Basic)
3-   |    INVOKE local guiobj word AppShow()
4-   |    INVOKE local guiobj word AppMaximize()
5-   |    INVOKE local guiobj word FileOpen (T:d:\reservation.doc)
6-   |    INVOKE local guiobj word EditGoTo (T:person)
7-    --- INVOKE local guiobj word InsertField (T:export_selected_customer)

The following table explains the sample code:

Line

Action

1

Builds an event to open a Word document and place information into it. This is the equivalent of the dimension statement (Step 1).

2

Sets a local view guiobj word to the CreateObject type library from Word. This creates the object (Step 2 object).

3

Invokes a method to show the Word application.

4

Invokes a method Word makes available to maximize the application (in this case the application is already running on the desktop).

5

Invokes a method to open the Word document reservation.doc.

6

Invokes a method to go the person place holder.

7

Invokes a method to insert the export view of the selected customer into the person place holder.