Table of contents
TOC
Collapse the table of content
Expand the table of content

Layers.Add Method (Visio)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Adds a new Layer object to a Layers collection.

Syntax

expression . Add( LayerName )

expression A variable that represents a Layers object.

Parameters

NameRequired/OptionalData TypeDescription
LayerNameRequiredStringThe name of the new layer.

Return Value

Layer

Example

The following macro shows how to add a Layer object to the Layers collection.

Public Sub AddLayer_Example() 

 Dim vsoDocument As Visio.Document 
 Dim vsoPages As Visio.Pages 
 Dim vsoPage As Visio.Page 
 Dim vsoLayers As Visio.Layers 
 Dim vsoLayer As Visio.Layer 

 'Add a document based on the Basic Diagram template. 
 Set vsoDocument = Documents.Add("Basic Diagram.vst") 

 'Get the Pages collection and add a page to the collection. 
 Set vsoPages = vsoDocument.Pages 
 Set vsoPage = vsoPages.Add 

 'Get the Layers collection and add a layer named "MyLayer" 
 'to the collection. 
 Set vsoLayers = vsoPage.Layers 
 Set vsoLayer = vsoLayers.Add("MyLayer") 

End Sub
© 2018 Microsoft