Using OLE Automation

The Object Linking and Embedding (OLE) architecture is based on a model of client-server (also known as container-component or controller-component) associations. This model is based on the interaction between two applications in which one application (the client or container) makes requests to the other (the server or client) to perform an action. With OLE Automation, the application acting as the server exposes one or more automation components which allow other applications (controller or client) to manipulate them. For example, WordPerfect can execute a macro containing commands that open Microsoft Word, open a document into Microsoft Word, modify the formatting, resave the document, and close Microsoft Word. In this case, WordPerfect is the OLE automation controller and Microsoft Word is the OLE automation server, since it acts upon the requests made by WordPerfect. When Microsoft Word, Visual Basic for Applications (VBA), or any other OLE automation controller application opens WordPerfect and instructs it to perform certain specified tasks using OLE automation methods, WordPerfect is the OLE automation server and the controlling application becomes the OLE automation controller.

PerfectScript can send commands to WordPerfect, Presentations, and Quattro Pro through OLE Automation. PerfectScript can also send commands to such applications as Microsoft Excel and Microsoft Word. These applications are called OLE Automation servers. PerfectScript is an OLE Automation controller. OLE Automation is not limited to these programs. PerfectScript can send commands to and control any OLE Automation server.

OLE Automation servers define objects. These objects have names that are registered with Windows. You can refer to an application’s documentation for the names of objects they define. OLE objects can have methods and properties. A method is a command or function that performs an action on that object. A property is a value that the object has (like system variables in WordPerfect.) You can retrieve and set this value. An example of a method for the “Excel.Application” object is as follows:


A property of the “Excel.Application” object is as follows:


Methods, like product commands, may require parameters, and may or may not return values. Unlike system variables in WordPerfect, you can set properties by placing the property name on the left-hand side of an assignment statement. Properties can also take parameters when being retrieved or when being set. This makes the retrieval of a property very similar to a method call.

Using OLE Automation