Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Documents.Add Method

Office 2007
Adds a new Document object to the Documents collection.

Version Information
 Version Added:  Visio 2.0

Syntax

expression.Add(FileName)

expression   A variable that represents a Documents object.

Parameters

NameRequired/OptionalData TypeDescription
FileNameRequiredStringThe type or file name of the document to add; if you do not 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 a template, pass "templatename.vst" 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").

To open a copy of a stencil, pass ("stencilname.vss").

To open a copy of a drawing, pass ("drawingname.vsd").

ms425621.vs_note(en-us,office.12).gif  Note
Opening a copy of a stencil or drawing is equivalent to selecting Copy in the Open list box of the Open dialog box or using the OpenEx method with the visOpenCopy flag.

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.

Visual Basic for Applications
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  



Community Additions

ADD
Show:
© 2015 Microsoft