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

Page.UniqueIDsToShapeIDs Method (Visio)

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

Returns an array of shape IDs of shapes on the page, as specifed by their unique IDs.

Note This Visio object or member is available only to licensed users of Visio Professional 2013.


expression . UniqueIDsToShapeIDs( GUIDs() , ShapeIDs() )

expression An expression that returns a Page object.


NameRequired/OptionalData TypeDescription
GUIDs()RequiredStringAn array of unique IDs of type String of shapes on the page.
ShapeIDs()RequiredLongOut parameter. An empty array that the method fills with shape IDs of type Long corresponding to the shapes specified in GUIDs()

Return Value



Microsoft Visio identifies shapes by two different IDs: shape IDs and unique IDs. Shape IDs are numeric and uniquely identify shapes within the scope of an individual drawing page. They are not unique within a wider scope, however.

Unique IDs are globally unique identifiers (GUIDs). They are unique within the scope of the application.

To convert between shape IDs and unique IDs, you can use two methods of the Page object, ShapeIDsToUniqueIDs and UniqueIDsToShapeIDs .

By default, a shape does not have a unique ID. A shape acquires a unique ID only if you set its Shape.UniqueID property.

If a Shape object has a unique ID, no other shape in any other document will have the same ID.


The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the UniqueIDsToShapeIDs method to determine the shape IDs of the shapes on the page passed to the method as unique IDs. It iterates through all the shapes on the active drawing page, using the UniqueID property of each shape to get the unique IDs of the shapes. Then it passes those unique IDs to the UniqueIDsToShapeIDs method to return the shape IDs of the shapes. It prints the unique IDs and shape IDs to the Immediate window.

Before running this macro, open a Visio drawing and place several shapes on the active drawing page.

Public Sub UniqueIDsToShapeIDs_Example() 

    Dim vsoShape As Visio.Shape 
    Dim intArrayCounter As Integer 
    Dim intShapeCount As Integer 

    intShapeCount = ActivePage.Shapes.Count 

    ReDim astrUniqueIDs(intShapeCount - 1) As String 
    ReDim alngShapeIDs(intShapeCount - 1) As Long 

    intArrayCounter = 0 

    For Each vsoShape In ActivePage.Shapes         
        astrUniqueIDs(intArrayCounter) = vsoShape.UniqueID(1) 
        Debug.Print astrUniqueIDs(intArrayCounter) 
        intArrayCounter = intArrayCounter + 1 

    ActivePage.UniqueIDsToShapeIDs astrUniqueIDs, alngShapeIDs 

    intArrayCounter = 0 

    For intArrayCounter = LBound(alngShapeIDs) To UBound(alngShapeIDs) 
        Debug.Print alngShapeIDs(intArrayCounter) 

End Sub
© 2017 Microsoft