Selection.Select メソッド (Visio)

オブジェクトを選択または選択解除します。

構文

選択 (SheetObjectSelectAction)

Selection オブジェクトを表す変数。

パラメーター

名前 必須 / オプション データ型 説明
SheetObject 必須 [IVSHAPE] 選択または選択解除する Shape オブジェクトを返す式です。
Selectaction 必須 Integer 実行する選択の種類です。

戻り値

なし

解説

Window オブジェクトに対して使用した場合、Select メソッドは Microsoft Office Visio ウィンドウでの選択に影響を与えます。 ただし Selection オブジェクトの場合は、ウィンドウでの選択に影響は与えません。 したがって、Selection オブジェクトに対して Select メソッドを使用した場合は、メモリ内のオブジェクトの状態のみが影響を受け、Visio のウィンドウには影響がありません。

Visio タイプ ライブラリの VisSelectArgs で宣言されている次の定数を、選択の種類の値として指定できます。

定数 説明
visDeselect 1 図形を選択解除しますが、残りの選択範囲は変更しません。
visSelect 2 図形を選択しますが、残りの選択範囲は変更しません。
visSubSelect 3 親が既に選択されている図形を選択します。
visSelectAll 4 ある図形、および同等の図形をすべて選択します。
visDeselectAll 256 ある図形、および同等の図形をすべて選択解除します。

SelectActionvisSubSelect である場合、SheetObject の親図形が既に選択されていなければなりません。

visDeselectAll を、visSelect および visSubSelect と組み合わせて使用すると、他の図形を選択する前に、すべての図形の選択を解除できます。

操作する図形が Selection オブジェクトの場合、Select メソッドで選択した Shape オブジェクトの ContainingShape プロパティが、その Selection オブジェクトの ContainingShape プロパティと異なっていると、Select メソッドによって、すべての選択が解除されます。選択の種類を示す値に選択解除を指定しない場合でも、すべての選択が解除されます。

操作対象のオブジェクトが Window オブジェクトで、SelectActionvisSubSelect ではない場合、SheetObject の親図形は、Window.Selection オブジェクトの ContainingShape プロパティが返す図形と同じでなければなりません。

次の Microsoft Visual Basic for Applications (VBA) マクロは、図形の選択および選択解除の方法を示します。

 
Public Sub Select_Example() 
 
 Const MAX_SHAPES = 6 
 Dim vsoShapes(1 To MAX_SHAPES) As Visio.Shape 
 Dim intCounter As Integer 
 
 'Draw six rectangles. 
 For intCounter = 1 To MAX_SHAPES 
 Set vsoShapes(intCounter) = ActivePage.DrawRectangle(intCounter, intCounter + 1, intCounter + 1, intCounter) 
 Next intCounter 
 
 'Cancel the selection of all the shapes on the page. 
 ActiveWindow.DeselectAll 
 
 'Create a Selection object. 
 Dim vsoSelection As Visio.Selection 
 Set vsoSelection = ActiveWindow.Selection 
 
 'Select the first three shapes on the page. 
 For intCounter = 1 To 3 
 vsoSelection.Select vsoShapes(intCounter), visSelect 
 Next intCounter 
 
 'Group the selected shapes. 
 'Although the first three shapes are now grouped, the 
 'array vsoShapes() still contains them. 
 Dim vsoGroup As Visio.Shape 
 Set vsoGroup = vsoSelection.Group 
 
 'There are now four shapes on the page - a group that contains three 
 'subshapes, and three ungrouped shapes. Subselection is 
 'accomplished by selecting the parent shape first or one of the 
 'group's shapes already subselected. 
 
 'Select parent (group) shape. 
 ActiveWindow.Select vsoGroup, visDeselectAll + visSelect 
 
 'Subselect two of the shapes in the group. 
 ActiveWindow.Select vsoShapes(1), visSubSelect 
 ActiveWindow.Select vsoShapes(3), visSubSelect 
 
 'At this point two shapes are subselected, but we want to 
 'start a new selection that includes the last two shapes 
 'added to the page and the group. 
 
 'Note that the subselections that were made in the group 
 'are canceled by selecting another shape that is 
 'at the same level as the parent of the subselected shapes. 
 
 'Select just one shape. 
 ActiveWindow.Select vsoShapes(MAX_SHAPES), _ 
 visDeselectAll + visSelect 
 
 'Select another shape. 
 ActiveWindow.Select vsoShapes(MAX_SHAPES - 1), visSelect 
 
 'Select the group. 
 ActiveWindow.Select vsoGroup, visSelect 
 
 'Select all but one shape on the page. 
 ActiveWindow.SelectAll 
 ActiveWindow.Select vsoShapes(MAX_SHAPES - 1), visDeselect 
 
End Sub

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。