Window.Selection Property
Visio Automation Reference |
Returns a Selection object that represents what is presently selected in the window, or assigns a selection created by the CreateSelection method to a Selection object. Read/write.
Version Information
Version Added: Visio 2.0
Syntax
expression.Selection
expression A variable that represents a Window object.
Return Value
Selection
Remarks
The Selection object is independent of the selection in the window, which can subsequently change as a result of user actions.
A Selection object is a set of shapes in a common context on which you can perform actions. A Selection object is analogous to more than selected shapes in a drawing window. Once you set or retrieve a Selection object, you can change the set of shapes the object represents by using the Select method.
After you use the CreateSelection method to create a selection, you can then use the Selection property to actually display the newly created selection in the Microsoft Office Visio drawing window. See the second example that follows.
Example
This Microsoft Visual Basic for Applications (VBA) macro shows how to use the Selection property to get all the selected shapes in the window.
Visual Basic for Applications |
---|
|
This VBA macro shows how to use the CreateSelection method to select all shapes on a particular layer. Then it uses the Selection property to display the selection in the Visio drawing window.
Before running this macro, create two layers in your drawing, one named "a" and one named "b", and then add shapes to both layers.
Visual Basic for Applications |
---|
|
See Also