Creating a New Document

If you need to create a new document, use the Documents collection's Add method: Documents.Add([Template][, NewTemplate][, DocumentType][, Visible])

Template This optional argument specifies the template file to use as the basis for the new document. Enter a string that spells out the path and name of the .DOT file. If you omit this argument, Word creates the new document based on the Normal template.

NewTemplate If you set this optional argument to True, Word creates a new template file.

DocumentType This optional argument determines the type of document that's created. Use one of the following constants:

wdNewBlankDocument wdNewEmailMessage wdNewFrameset wdNewWebPage wdNewXMLDocument

Creates a new, blank Word document (this is the default). Creates a new email message. Creates a new web frameset page. Creates a new web page. Creates a new XML document.


This is an optional Boolean value that determines whether Word displays the new document in a visible window. True is the default; use False to create the document without displaying it in a visible window.

Because all the Add method's arguments are optional, you can create a basic Word document based on the Normal template with the following simple statement: Documents.Add

ยก^ After you create a new document,it automatically becomes the active document in the Word win-0 dow,so you can use the ActiveDocument property to work with the new document (for example, to save it, as discussed in the next section.

0 0

Post a comment