Page.UniqueIDsToShapeIDs Method (Visio)

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 Microsoft Visio Professional 2010 or Visio Premium 2010.

Version Information

Version Added: Visio 2007

Syntax

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

expression An expression that returns a Page object.

Parameters

Name

Required/Optional

Data Type

Description

GUIDs()

Required

String

An array of unique IDs of type String of shapes on the page.

ShapeIDs()

Required

Long

Out parameter. An empty array that the method fills with shape IDs of type Long corresponding to the shapes specified in GUIDs()

Return Value

Nothing

Remarks

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.

Example

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 
    Next 
    
    ActivePage.UniqueIDsToShapeIDs astrUniqueIDs, alngShapeIDs 
     
    intArrayCounter = 0 
 
    For intArrayCounter = LBound(alngShapeIDs) To UBound(alngShapeIDs) 
        Debug.Print alngShapeIDs(intArrayCounter) 
    Next 
 
End Sub