Selection.Select Method
Visio Automation Reference |
Selects or clears the selection of an object.
Version Information
Version Added: Visio 2.0
Syntax
expression.Select(SheetObject, SelectAction)
expression A variable that represents a Selection object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
SheetObject | Required | [IVSHAPE] | An expression that returns a Shape object to select or clear. |
SelectAction | Required | Integer | The type of selection action to take. |
Return Value
Nothing
Remarks
When used with the Window object, the Select method will affect the selection in the Microsoft Office Visio window. The Selection object, however, is independent of the selection in the window. Therefore, using the Select method with a Selection object only affects the state of the object in memory; the Visio window is unaffected.
The following constants declared by the Visio type library in VisSelectArgs show valid values for selection types.
Constant | Value | Description |
---|---|---|
visDeselect |
1 |
Cancels the selection of a shape but leaves the rest of the selection unchanged. |
visSelect |
2 |
Selects a shape but leaves the rest of the selection unchanged. |
visSubSelect |
3 |
Selects a shape whose parent is already selected. |
visSelectAll |
4 |
Selects a shape and all its peers. |
visDeselectAll |
256 |
Cancels the selection of a shape and all its peers. |
If SelectAction is visSubSelect, the parent shape of SheetObject must already be selected.
You can combine visDeselectAll with visSelect and visSubSelect to cancel the selection of all shapes prior to selecting or subselecting other shapes.
If the object being operated on is a Selection object, and if the Select method selects a Shape object whose ContainingShape property is different from the ContainingShape property of the Selection object, the Select method clears everything, even if the selection type value does not specify canceling the selection.
If the object being operated on is a Window object, and if SelectAction is not visSubSelect, the parent shape of SheetObject must be the same shape as that returned by the ContainingShape property of the Window.Selection object.
Example
This Microsoft Visual Basic for Applications (VBA) macro shows how to select, clear, and subselect shapes.
Visual Basic for Applications |
---|
|
See Also