Chapter Twenty-Five

Automation

After reading Chapter 24, you should know what an interface is; you've already seen two standard COM interfaces, IUnknown and IClassFactory. Now you're ready for "applied" COM, or at least one aspect of it—Automation (formerly known as OLE Automation). You'll learn about the COM IDispatch interface, which enables C++ programs to communicate with Microsoft Visual Basic for Applications (VBA) programs and with programs written in other scripting languages. In addition, IDispatch is the key to getting your COM object onto a Web page. You'll use the MFC library implementation of IDispatch to write C++ Automation component and client programs. Both out-of-process components and in-process components are explored.

But before jumping into C++ Automation programming, you need to know how the rest of the world writes programs. In this chapter, you'll get some exposure to VBA as it is implemented in Microsoft Excel. You'll run your C++ components from Excel, and you'll run Excel from a C++ client program.