You cannot assign an OLE control (object type OLEControl) or ActiveX control (object type OLECustomControl) to an OLEObject.
If the vendor of the control exposes a programmatic identifier (in the form vendor.application), you can specify this identifier in the ConnectToNewObject function to connect to the programmable interface without the visual control. For an ActiveX control with events, this technique makes the events unavailable. ActiveX controls are not meant to be used this way and would not be useful in most cases.
You can assign the Object property of an OLE control to an OLEObject variable or use it as an OLEObject in a function.
For example, if you have an OLEControl ole_1 and an OLECustomControl ole_2 in a window and you have declared this variable:
OLEObject oleobj_automate
then you can make these assignments:
oleobj_automate = ole_1.Object oleobj_automate = ole_2.Object
You cannot assign an OLEObject to the Object property of an OLE control because it is read-only. You cannot make this assignment:
ole_1.Object = oleobj_automate //Error!
You can implement events for an OLEObject by creating a user object that is a descendant of OLEObject. The SetAutomationPointer PowerScript function assigns an OLE automation pointer to the descendant so that it can use OLE automation.
Suppose oleobjectchild is a descendant of OLEObject that implements events such as the ExternalException and Error events. The following code creates an OLEObject and an instance of oleobjectchild, which is a user object that is a descendant of OLEObject, connects to Excel, then assigns the automation pointer to the oleobjectchild:
OLEObject ole1 oleobjectchild oleChild ole1 = CREATE OLEObject ole1.ConnectToNewObject( "Excel.Application") oleChild = CREATE oleobjectchild oleChild.SetAutomationPointer( ole1 )
You can now use olechild for automation.