Getting and setting properties
Properties of OLE automation objects are also accessed by their unique name or DISPID. The OleAutomationObject class has these property-accessor instance methods:
Returns the value of a named property
Sets the value of a named property
These methods function like the invoke methods with respect to parameters and return values.
As an example of using the property methods on an OleAutomationObject, consider the following code fragment that opens Microsoft Excel, makes it visible, changes the default file path, and opens a file:
| excel application workBooks |
excel := OleAutomationObject createObject: 'Excel.Sheet'.
"Get the root Excel Application object."
application := excel propertyAt: 'Application'.
"Make Excel visible."
application propertyAt: 'Visible' put: true.
"Set the default file path."
application propertyAt: 'DefaultFilePath' put: 'c:\budget\'.
"Get the Excel Workbooks object."
workBooks := application propertyAt: 'Workbooks'.
"Open an existing Excel file (.XLS)."
workBooks invoke: 'Open' withArguments: #('budget96.xls').
application invoke: 'Quit' withArguments: #()
Last modified date: 01/29/2015