Export (0) Print
Expand All

Selection.GetIDs Method (Visio)

Published: July 16, 2012

Gets the shape IDs of the shapes in the selection.

Note Note

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

Version Added: Visio 2007

expression .GetIDs(ShapeIDs())

expression An expression that returns a Selection object.




Data Type





Out parameter. An array of shape IDs of type Long corresponding to the shapes in the selection.

Return Value


Microsoft Visio uses ID numbers to identify shapes, recordsets, and data rows. Shape IDs are unique only within the scope of the page they are on. After you determine these shape IDs, you can pass them to the Page.LinkShapesToDataRows method to specify exactly how the shapes in your diagram should link to data rows in the available data recordsets. Shape IDs are unique within the scope of a particular page.

To determine the shape ID for a shape that is part of a selection, use the Selection.GetIDs method.

The set of shape IDs returned is determined by the setting of the Selection.IterationMode property.

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the GetIDs method to get the IDs of shapes in a selection and print the IDs in the Immediate window. It selects all the shapes in the active window.

Public Sub GetIDs_Example() 
    Dim vsoSelection As Visio.Selection 
    Dim lngShapeIDs() As Long 
    Dim lngShapeID As Long 
    Set vsoSelection = ActiveWindow.Selection 
    Call vsoSelection.GetIDs(lngShapeIDs) 
    For lngShapeID = LBound(lngShapeIDs) To UBound(lngShapeIDs) 
        Debug.Print lngShapeID 
End Sub

Community Additions

© 2014 Microsoft