Masters.AddEx method (Visio)

Adds a new Master object of the specified type to the Masters collection of a Microsoft Visio document.

Syntax

expression. AddEx( _Type_ )

expression A variable that represents a Masters object.

Parameters

Name Required/Optional Data type Description
Type Required VisMasterTypes A master type from the VisMasterTypes enumeration. See Remarks for possible values.

Return value

Master

Remarks

For the Type parameter, pass one of the following members of VisMasterTypes, which is declared in the Visio type library.

Constant Value Description
visTypeMaster 1 Creates a shape master.
visTypeFillPattern 2 Creates a fill-pattern master.
visTypeLinePattern 3 Creates a line-pattern master.
visTypeLineEnd 4 Creates a line-end master.
visTypeDataGraphic 5 Creates a data graphic master.
visTypeThemeColors 6 Creates a theme-colors master.
visTypeThemeEffects 7 Creates a theme-effects master.

The AddEx method returns the Master object added.

If the master added is of type visTypeDataGraphic, Visio names it "Data Graphic", and if it is not the first data graphic in the Masters collection of the document, Visio appends the index number of the master in the collection to the name. For example, if there were already 5 objects in the Masters collection, one of which was a data graphic, the next data graphic added would be named "Data Graphic.6".

Naming of masters of type visTypeThemeColors and visTypeThemeEffects follows the same pattern, and the resulting new masters are named "Theme Colors. x " and "Theme Effects. x " respectively, where x is the index number in the collection. Masters of all other types are simply named "Master. x ".

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the AddEx method to add a new Master object of type visTypeDataGraphic to the Masters collection of the active document.

Public Sub AddEx_Example() 
 
    Dim vsoMaster As Visio.Master 
     
    Set vsoMaster = Visio.ActiveDocument.Masters.AddEx(visTypeDataGraphic) 
     
    Debug.Print vsoMaster.Name 
 
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.