Creating OLE Automation Objects
These are the ways to obtain OleAutomationObjects:
Create them directly using their ProgId, or client name, from the system registry.
Request them from another OleAutomationObject.
Request them from an existing OleClient that contains an embedded or linked OLE object.
Request them from an existing OleControl (see Using OLE custom controls (OCXs)).
You use the class method createObject: to instantiate an OleAutomationObject using a ProgId from the system registry. For example, Word Basic, the only OLE automation object exposed by Microsoft Word, has a ProgId of 'Word.Basic', so an instance of that object is created using:
| wordbasic |
wordbasic := OleAutomationObject createObject: 'Word.basic'
Unlike Microsoft Word, many OLE automation servers provide a number of automation objects organized as networks of interrelated objects. As such, one OLE automation object may reference another. The references to other automation objects are maintained as properties of the object. Values of an OLE automation object's properties are obtained by their name or DISPID. Support for property access by an OleAutomationObject is through its propertyAt: instance method, and, hence, additional OLE automation objects are obtained through this method. For example, the top-level application object of Microsoft Excel is accessed using:
| excel application |
excel := OleAutomationObject createObject: 'Excel.Sheet'.
application := excel propertyAt: 'Application'.
Many, but not all, OLE document servers also provide OLE automation objects. An OleClient, through its automationObject instance method, may answer the automation object of its embedded or linked OLE object. For example, if a Microsoft Word object is embedded in a container, its Word Basic automation object is obtained using:
| word wordDispatch wordApplication wordBasic |
word := mainWindow
createOleClient: 'word'
argBlock: [:w |
w
clientType: XmEMBEDDED;
clientName: 'Word.Document'].
word isConnected ifFalse: [word destroyWidget. ^nil].
word manageChild.
wordDispatch := word automationObject.
wordApplication := wordDispatch propertyAt: 'Application'.
wordBasic := wordApplication propertyAt: 'WordBasic'.
Last modified date: 01/29/2015