O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix A. Programming Word from Another Application

In this appendix, I describe briefly how the Word object model can be programmed from within certain other applications, including Microsoft Access, Excel, and PowerPoint. A well-known technique that Microsoft refers to as Automation (formerly called OLE Automation) allows one application to gain access to the objects of another. An application that “exposes” its objects is called an Automation server. An application that can access the objects of an Automation server is called an Automation controller or Automation client. Since Microsoft Word, Access, and Excel are both Automation servers and Automation controllers, as a VBA programmer, you can program any of these applications from within any other.

Setting a Reference to the Word Object Model

The first step in communicating with the Word object model is to set a reference to its object library. Each of the client applications (Word, Access, PowerPoint, and Excel) has a References menu item under the Tools menu. Selecting this item displays the References dialog box shown in Figure A-1. From here, you can select the object models that you want to access from within the Automation controller. (Note the second entry under Available References.)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required