Opening, Closing, and Creating New Documents

The most fundamental VBA commands look similar in Word, Excel, PowerPoint, and FrontPage—and very different in Outlook and Access.

Using VBA to Open, Close, and Create Word Documents

In Word, the command to create a new document based on the normal document template (Normal.dot) looks like this:

Documents.Add

If you want to base the new document on a different template, add the full path to the template:

Documents.Add "c:\ Program Files\ Microsoft Office\ Templates\ Company\ Invoice.dot"

To open an existing file—C:\ My Documents\ Invoice1049.doc, for example—use the Open method:

|Open method
|methods|Open
Documents.Open "C:\ My Documents\ Invoice1049.doc"

The Open method not only opens the document, ...

Get Special Edition Using Microsoft® Office XP 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.