Muokkaa

Jaa


Documents.Add method (Word)

Returns a Document object that represents a new, empty document added to the collection of open documents.

Syntax

expression.Add (Template, NewTemplate, DocumentType, Visible)

expression Required. A variable that represents a Documents object.

Parameters

Name Required/Optional Data type Description
Template Optional Variant The name of the template to be used for the new document. If this argument is omitted, the Normal template is used.
NewTemplate Optional Variant True to open the document as a template. The default value is False.
DocumentType Optional Variant Can be one of the following WdNewDocumentType constants: wdNewBlankDocument, wdNewEmailMessage, wdNewFrameset, or wdNewWebPage. The default constant is wdNewBlankDocument.
Visible Optional Variant True to open the document in a visible window. If this value is False, Microsoft Word opens the document but sets the Visible property of the document window to False. The default value is True.

Return value

Document

Example

This example creates a new document based on the Normal template.

Documents.Add

This example creates a new document based on the Professional Memo template.

Documents.Add Template:="C:\Program Files\Microsoft Office" _ 
 & "\Templates\Memos\Professional Memo.dot"

This example creates and opens a new template, using the template attached to the active document as a model.

tmpName = ActiveDocument.AttachedTemplate.FullName 
Documents.Add Template:=tmpName, NewTemplate:=True

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.