Chapter 20

Automating Word

In this chapter, you will:

  • Use early and late binding to reference a Word object

  • Use the New keyword to reference the Word application

  • Use the CreateObject function to create a new instance of an object

  • Use the GetObject function to reference an existing instance of Word

  • Use constant values

  • Be introduced to some of Word’s objects

  • Control form fields in Word

Word, Excel, PowerPoint, Outlook, and Access all use the same VBA language. The only difference is their object models. For example, Excel has a Workbooks object, and Word has Documents. Any one of these applications can access the object model of another application, as long as the second application is installed.

To access Word’s object library, Excel must establish ...

Get Microsoft Excel VBA and Macros (Office 2021 and Microsoft 365) 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.