OLE Automation

What is OLE Automation?

OLE Automation is a standard, promoted by Microsoft, that applications use to expose their OLE objects to development tools, Enable Basic, and containers that support OLE Automation. A spreadsheet application may expose a worksheet, chart, cell, or range of cells all as different types of objects. A word processor might expose objects such as application, paragraph, sentence, bookmark, or selection.

Some applications provide objects that support OLE Automation. You can use Enable Basic to programmatically manipulate the data in these objects. Some objects that support OLE Automation also support linking and embedding. You can create an OLE Automation object by using the CreateObject function.

When an application supports OLE Automation, the objects it exposes can be accessed by Enable Basic. You can use Enable Basic to manipulate these objects by invoking methods on the object, or by getting and setting the object’s properties, just as you would with the objects in Enable Basic.

For example, if you created an OLE Automation object named MyObj, you might write code such as this to manipulate the object:

Sub Main

Dim MyObj As Object

Set MyObj = CreateObject ("Word.Basic")

MyObj.FileNewDefault

MyObj.Insert "Hello, world."

MyObj.Bold 1

End Sub

The following syntax is supported for the GetObject function:

  1. Set MyObj = GetObject ("", class)

 

Where class is the parameter representing the class of the object to retrieve. The first parameter at this time must be an empty string.

The properties and methods an object supports are defined by the application that created the object. See the application's documentation for details on the properties and methods it supports.