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

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

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