Szerkesztés

Megosztás a következőn keresztül:


Documents.Add method (Visio)

Adds a new Document object to the Documents collection.

Syntax

expression.Add (FileName)

expression A variable that represents a Documents object.

Parameters

Name Required/Optional Data type Description
FileName Required String The type or file name of the document to add; if you don't include a path, Visio searches the folder or folders designated in the Application object's TemplatePaths property and all published templates, including published third-party templates.

Return value

Document

Remarks

To create a new drawing based on no template, pass a zero-length string ("") to the Add method.

To create a new drawing based on another file, like a template, pass the filename of the original file to the Add method. Visio opens stencils that are part of the template's workspace and copies styles and other settings associated with the template to the new document. If the template file name is invalid, no document is returned and an error is generated.

To create a new stencil based on no stencil, pass ("vss").

Note

Passing a filename as an argument to the Add method is equivalent to opening a file like a template, where a new blank drawing is created that includes content copied from the original.

Example

The following macro shows how to add Document objects such as templates, stencils, and drawings to the Documents collection.

Before running this macro, replace Myfile.vsd with a valid .vsd file.

Public Sub AddDocument_Example() 
 
 Dim vsoDocument As Visio.Document 
 
 'Add a Document object based on the Basic Diagram template. 
 Set vsoDocument = Documents.Add("Basic Diagram.vst") 
 
 'Add a Document object based on a drawing (creates a copy of the drawing). 
 Set vsoDocument = Documents.Add("Myfile.vsd ") 
 
 'Add a Document object based on a stencil (creates a copy of the stencil). 
 Set vsoDocument = Documents.Add("Basic Shapes.vss") 
 
 'Add a Document object based on no template. 
 Set vsoDocument = Documents.Add("") 
 
End Sub

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.