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

Styles.Add Method (Visio)

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

Adds a new Style object to a Styles collection.


expression . Add( StyleName , BasedOn , fIncludesText , fIncludesLine , fIncludesFill )

expression A variable that represents a Styles object.


NameRequired/OptionalData TypeDescription
StyleNameRequiredStringThe new style name.
BasedOnRequiredStringThe name of the style on which to base the new style.
fIncludesTextRequiredIntegerZero to disable text attributes, or non-zero to enable them.
fIncludesLineRequiredIntegerZero to disable line attributes, or non-zero to enable them.
fIncludesFillRequiredIntegerZero to disable fill attributes, or non-zero to enable them.

Return Value



To base the new style on no style, pass a zero-length string ("") for the BasedOn argument.


The following macro shows how to add Style objects to the Styles collection. It shows how to add a new style based on an existing style, as well as how to add a new style created from scratch.

Public Sub AddStyle_Example() 

 Dim vsoDocument As Visio.Document 
 Dim vsoStyles As Visio.Styles 
 Dim vsoStyle As Visio.Style 

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

 'Add a style named "My FillStyle" to the Styles collection. 
 'This style is based on the Basic style and includes 
 'only a Fill style. 
 Set vsoStyles = vsoDocument.Styles 
 Set vsoStyle = vsoStyles.Add("My FillStyle", "Basic", 0, 0, 1) 

 'Add a style named "My NoStyle" to the Styles collection. 
 'This style is not based on an existing style and includes 
 'Text, Line, and Fill styles. 
 Set vsoStyle = vsoStyles.Add("My NoStyle", "", 1, 1, 1) 

End Sub
© 2018 Microsoft