Chapter 12. The Document Object

In this chapter:

  • Properties That Return Collections

  • Spelling-Related Properties and Methods

  • The Documents Collection

  • Adding, Opening, and Saving Documents

  • Password-Related Properties

  • Protection-Related Properties and Methods

  • The Name Properties

  • Printing-Related Methods

  • Additional Members of the Document Object

  • Children of the Document Object

A Document object represents a Word document. Document objects are kept in the Documents collection, which contains all currently opened documents.

The Documents property of the Application object is global, so we can access the Documents collection simply by writing:

	Documents

For instance, the code:

	MsgBox Documents.Count

displays the number of currently open documents.

Perhaps the most commonly used property of the Application object is the ActiveDocument property, which returns a Document object that represents the currently active Word document.

Figure 12-1 shows the children of the Document object.

The Document object

Figure 12-1. The Document object

Figure 12-2 shows the children of the Document object that I discuss specifically, either in this chapter and in subsequent chapters. First, however, I take a look at some of the properties and methods of the Document object.

Selected children of the Document object

Figure 12-2. Selected children of the Document object

Get Writing Word Macros, Second Edition 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.