PowerScript Automation Facilities
\The Sandbox \PB History & Future \New in PB 4 \OLE 2.0 \PowerScript Automation
Drag Target
Editing a
Report
Embedding
a Report
InPlace
Activation
MergeOption
OLE 2.0
Container App
OLE 2.0
Control Functions
OLE Automation
Functions
OLE Control
OLE Features &
InfoMaker
OLE 2.0 Support
PowerScript
Automation
Registering
Reports
Saving Embedded
or Linked Objects

New PowerScript functions provide the ability to write scripts to automate OLE 2.0 server applications and OLE 2.0 controls.

A dynamic object type, OLEObject, is new in Version 4.0 to support OLE 2.0. For this object type, the compiler will accept attribute names, function names, and parameter lists which are not already defined for the object. These functions may or may not be present during execution. If they are not present during execution, you will get errors.

The following steps outline automation of an OLE 2.0 server application from PowerBuilder. For complete information, see the Building Applications manual.

  1. Declare a variable of type OLEObject
  2. OLEObject MyOLEObject

  3. Create an OLEObject
  4. MyOLEObject = Create OLEObject

  5. Connect to an OLE 2.0 server
  6. MyOLEObject.ConnectToNewObject (string classname)

    example: MyOLEObject.ConnectToNewObject("excel.application")

    or Connect to an existing file

    MyOLEObject.ConnectToObject (string filename)

    example: MyOLEObject.ConnectToObject("c:\excel\expense.xls")

  7. Use server methods - (MS Excel example)
  8. // The following line makes excel visible
    MyOLEObject.application.visible = true
    // Before you try to execute the following line, you must do a File/New in excel.
    MyOLEObject.application.cells(1, 1).value = 14

  9. Destroy OLEObject (This step is important.)
  10. Destroy MyOLEObject

If you want to use automation for an OLE 2.0 control, you can simply call the servers methods prefacing it with the Object attribute of your OLE 2.0 control.  Note, you do not need to do any of the steps listed above.

Use the server methods with your OLE 2.0 control - (MS Excel example)

    OLE_1.object.application.cells(1, 1).value = 14

    Note: OLE_1 is an OLE 2.0 control 

PBL Peeper PB Help PB History
& Future About Us Feedback Site Map

Google
 
Web www.techno-kitten.com
www.sybase.com