Controlling an Office Application from VBA

So far in this chapter, we've focused on the components inside VBA—projects, modules, custom dialog boxes, controls, events, and the like. Ultimately, however, almost every VBA program interacts with the underlying application: For example, you usually write a VBA/Word macro to perform some sort of action on a Word document. That isn't an absolute requirement—you can write a VBA/Excel macro that doesn't interact with any workbooks—but in most cases you will want your program to control the underlying application.

That's where the object model comes in. When a VBA/Word macro controls Word, it does so by using the Word object model. When a VBA/PowerPoint macro changes a slide, it uses the PowerPoint object ...

Get Special Edition Using Microsoft® Office XP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.