SetAutomationPointer

Description

Sets the automation pointer of an OLEObject object to the value of the automation pointer of another object.

Applies to

OLEObject

Syntax

oleobject.SetAutomationPointer ( object )

Argument

Description

oleobject

The name of an OLEObject variable whose automation pointer you want to set. You cannot specify an OLEObject that is the Object property of an OLE control.

object

The name of an OLEObject variable that contains the automation pointer you want to use to set the pointer value in oleobject.


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:

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:\temp\expenses.xls")
      oleChild.cells(1,1).value = 11111
      oleChild.activeworkbook.saveas( &
         "d:\temp\newexp.xls")
      oleChild.activeworkbook.close()
      oleChild.quit()
END IF
ole1.disconnectobject()
DESTROY oleChild
DESTROY ole1