Using OLE Automation

With the introduction of Visual Basic for Applications (VBA) in Microsoft Excel 5.0, a new method of communicating with Microsoft Excel was provided: OLE Automation. VBA is not an intrinsic part of Microsoft Excel. It is implemented as a series of DLLs and uses Automation to communicate with Microsoft Excel. This provides maximum reusability among the various pieces of Microsoft Office.

OLE Automation provides a mechanism for a controller (VBA) to interact with an object (Microsoft Excel). This is a two-way interaction. Because OLE Automation is a protocol, any automation controller can use every automation object, and any automation object can be used by every automation controller. This communication is typified by calling "methods" and setting "properties." Methods equate to function calls, and properties equate to setting the value of a variable.

This chapter focuses on OLE Automation from a Microsoft Excel and a Visual Basic point of view. The concepts discussed also apply to OLE Automation controllers built in C/C++, but the actual details of building these controllers are beyond the scope of this book.