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

Viewer.OnSelectionChanged Event (Visio Viewer)

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

Occurs when the shape selection is changed in Microsoft Visio Viewer.


expression. OnSelectionChanged( ShapeIndex)

_expression_An expression that returns a Viewer object.


NameRequired/OptionalData TypeDescription
ShapeIndexRequiredLongThe index of the newly selected shape.

Return Value



The collection of shapes in the Viewer is one-based, so the first shape in the collection has index 1.

You can change the selected shape in Visio Viewer programmatically by using the SelectShape method.


The following code shows how to use the OnSelectionChanged event to print the ID of the newly selected shape in Visio Viewer in the Immediate window.

Private Sub vsoViewer_OnSelectionChanged(ByVal ShapeIndex As Long)

    Debug.Print "Selected shape changed to shape " &; vsoViewer.SelectedShapeIndex &; "."

End Sub
© 2018 Microsoft