|< Day Day Up >|
The techniques you've used so far in this book have been anchored firmly in the capabilities of Microsoft Access itself. But as you undoubtedly know, Access is part of the Microsoft Office suite, a group of products designed to be used together. That's where automation comes in. By writing automation code, you can use one application (such as Access) to control another application (such as Word, PowerPoint, or Excel). This capability isn't limited just to Microsoft Office applications. There are hundreds of other applications, from AutoCAD to XMLSpy, that can be controlled by automation.
Automation code always involves two applications: a client and a server. The client is the application where the VBA code is running; in this case, it's always Access. The server is the application that supplies functionality to the automation code. The client creates one or more objects from the server, and then uses the methods and properties of those objects to do something useful.
For example, an Access application can use automation, with Microsoft Word as the server application, to create a new Word document. Having created the document (by making a new Word.Document object), the Access code can go on to set the document's properties, add and format text, and save it with a particular filename. The result is the creation of a Word .doc file without ever leaving Access.
Automation doesn't bring objects from one application into another. Rather, it lets one application control objects that are supplied by another application. This is an important distinction. If you're using Microsoft Word as an automation server, for example, the users must still have Word installed on their computers to run your code. But they don't have to open Word and manipulate it by hand. Your automation code can do that for them.
If there's any chance that users might try to run your automation code on a system that doesn't have the required server application installed, be sure to include error trapping to prevent the inevitable errors from terminating your application.
|< Day Day Up >|