Additional Members of the Document Object
Some additional members of the Document object include:
- The Activate method
Activates the document, thus making it the active document. For instance, to activate a document named MyLetter, execute the code:
Documents("MyLetter").Activate
- The AttachedTemplate property
Returns a Template object that represents the template that is currently attached to the document. By setting this property, you can attach a new template to the document. For instance, the following code attaches the template FaxDocs to the current document:
ActiveDocument.AttachedTemplate = "FaxDocs.dot"
- The ComputeStatistics method
This method returns information about the document. It syntax is:
DocumentObject.
ComputeStatistics(Statistic, IncludeFootnotesAndEndnotes
)where
Statistic
is one of the following constants:Enum WdStatistic wdStatisticWords = 0 wdStatisticLines = 1 wdStatisticPages = 2 wdStatisticCharacters = 3 wdStatisticParagraphs = 4 wdStatisticCharactersWithSpaces = 5 End Enum
The parameter
IncludeFootnotesAndEndnotes
is set to True to include footnotes and endnotes when computing the requested information. The default value of this parameter is False.Incidentally, Word can supply more statistics about a document through the DocumentStatistics dialog box. (I explain how to access this information at the end of Chapter 19, Built-in Dialog Objects.)
- The Content property
This useful property returns a Range object that represents the main document story. (I show it ...
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.