SetAutomationPointer
PowerScript function
Description
Sets the automation pointer of an OLEObject object to the value of
the automation pointer of another object.
Applies to
OLEObject
Syntax
1 |
oleobject.SetAutomationPointer ( object ) |
Argument |
Description |
---|---|
oleobject |
The name of an OLEObject variable whose automation pointer |
object |
The name of an OLEObject variable that contains the |
Return value
Integer.
Returns 0 if it succeeds and -1 if the object does not contain a
valid OLE automation pointer.
Usage
SetAutomationPointer assigns the underlying automation pointer used
by OLE into a descendant of OLEObject.
Examples
This example creates an OLEObject variable and calls
ConnectToNewObject to create a new Excel object and connect to it. It also
creates an object of type oleobjectchild (which is a descendant of
OLEObject) and sets the automation pointer of the descendant object to the
value of the automation pointer in the OLEObject object. Then it sets a
value in the worksheet using the descendant object, saves it to a
different file, and destroys both objects:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
OLEObject ole1 oleobjectchild oleChild integer rs ole1= CREATE OLEObject rs = ole1.ConnectToNewObject("Excel.Application") oleChild = CREATE oleobjectchild rs = oleChild.SetAutomationPointer(ole1 ) IF ( rs = 0 ) THEN oleChild.workbooks.open("d: empexpenses.xls") oleChild.cells(1,1).value = 11111 oleChild.activeworkbook.saveas( & "d: emp ewexp.xls") oleChild.activeworkbook.close() oleChild.quit() END IF ole1.disconnectobject() DESTROY oleChild DESTROY ole1 |