Automation and OLE provide a sophisticated means for you to work with objects or documents provided by one component from within another component. A component is an application or development tool that makes its objects available to other applications. Not every component supports Automation or OLE, so you should check the other component’s documentation to determine whether it does.
Automation and OLE are both features of the Component Object Model, an industry standard used by components to expose their objects to other components and development tools. However, Automation and OLE are two distinct technologies. The following section outlines the differences between the two.
Automation is a technology that you can use to work with the objects in another component’s object model. Automation gives you the same degree of control over a component that you would have if you were programming in the component itself. You can perform Automation only using Visual Basic.
For example, you can write code in Microsoft Access to work with the objects in the Microsoft Word object model. Microsoft Word includes a thesaurus, but Microsoft Access doesn’t. You can use Automation from Microsoft Access to look up synonyms in the Microsoft Word thesaurus.
See Also For more information on object models, see Chapter 5, “Working with Objects and Collections.”
OLE is a technology that you can use to include objects created in another component on a Microsoft Access form or report. These objects can be embedded or linked. An embedded object is a copy of an object that is saved with a form or report. Linked objects are objects that exist in another file and are simply displayed on the form or report.
Once you’ve embedded or linked an object, you can activate the component in which it was created from within Microsoft Access. For example, you can embed a Microsoft Word document in a Microsoft Access form. When you double-click the embedded document, Microsoft Word opens and you can edit the document.
An object that can be linked or embedded in a form or report is called an OLE object. Microsoft Word and Microsoft Excel documents and Windows Paint pictures can be OLE objects. Some multimedia files, such as .avi video clips and .wav sound files, are also OLE objects. OLE objects are different from Automation objects in that they are objects produced by the component rather than a part of the component’s object model.
You can perform simple OLE operations without writing Visual Basic code. For a greater degree of control over OLE objects, you can also work with them in Visual Basic.
Some components support both Automation and OLE. For example, Microsoft Excel documents (.xls files) are OLE objects. You can include a Microsoft Excel document on a Microsoft Access form or report. Microsoft Excel also has an object model that you can use to work with Microsoft Excel objects using Visual Basic. The Microsoft Excel object model includes Workbook objects, Worksheet objects, Range objects, and so on. You can access these objects from Microsoft Access or from another component that supports Automation.
OLE objects are useful when the user of your Microsoft Access application needs to see and work with data in another component. For example, if you want users to be able to make changes to a Microsoft Excel spreadsheet, you can embed that spreadsheet in a form.
When you write Automation code, on the other hand, your code controls everything that the other component does. An Automation operation can be completely invisible to the user. For example, Microsoft Excel has a set of powerful built-in mathematical functions. You can use Automation to execute Microsoft Excel’s functions on Microsoft Access data without the user ever seeing the Microsoft Excel component.