Shape.ConnectedShapes メソッド (Visio)
図形に接続されている図形の識別子 (ID) を配列として返します。
構文
expression.
ConnectedShapes
( _Flags_
, _CategoryFilter_
)
式: Shape オブジェクトを表す変数。
パラメーター
名前 | 必須 / オプション | データ型 | 説明 |
---|---|---|---|
Flags | 必須 | VisConnectedShapesFlags | 返された図形の ID の配列に、コネクターの方向でフィルターを適用します。 指定可能な値については、「備考」を参照してください。 |
CategoryFilter | 必須 | String | 返された図形の ID の配列にフィルターを適用し、指定したカテゴリと一致する図形の ID に制限します。 |
戻り値
Long()
解説
Flags パラメーターの値には、次に示す VisConnectedShapesFlags クラスの定数のいずれかを指定する必要があります。
定数 | 値 | 説明 |
---|---|---|
visConnectedShapesAllNodes | 0 | 入力方向と出力方向の両方の接続に関連付けられた図形の ID を返します。 |
visConnectedShapesIncomingNodes | 1 | 入力方向の接続に関連付けられた図形の ID を返します。 |
visConnectedShapesOutgoingNodes | 2 | 出力方向の接続に関連付けられた図形の ID を返します。 |
カテゴリは、図形を分類し、それによってコンテナーのメンバーシップを制限するために使用できるユーザー定義文字列です。 カテゴリは、図形のシェイプシート内の User.msvShapeCategories セルで定義できます。 1 つの図形に対して複数のカテゴリを定義するには、カテゴリをセミコロンで区切ります。
ソース オブジェクトが 1D 図形またはマスター シェイプの一部である場合、 ConnectedShapes メソッドは無効なソース エラーを返します。
接続された有効な図形が存在しない場合、ConnectedShapes メソッドは空の配列を返します。
例
次のVisual Basic for Applications (VBA) マクロは、ConnectedShapes メソッドを使用して、選択した図形から発信接続のもう一方の端にあるすべての図形の名前を検索する方法を示しています。
提供されるサンプル コード:Fred Diggs
Public Sub ConnectedShapes_Outgoing_Example()
' Get the shapes that are connected to the selected shape
' by outgoing connectors.
Dim vsoShape As Visio.Shape
Dim lngShapeIDs() As Long
Dim intCount As Integer
If ActiveWindow.Selection.Count = 0 Then
MsgBox ("Please select a shape that has connections")
Exit Sub
Else
Set vsoShape = ActiveWindow.Selection(1)
End If
lngShapeIDs = vsoShape.ConnectedShapes _
(visConnectedShapesOutgoingNodes, "")
Debug.Print "Shapes at the end of outgoing connectors:"
For intCount = 0 To UBound(lngShapeIDs)
Debug.Print ActivePage.Shapes(lngShapeIDs(intCount)).Name
Next
End Sub
次の VBA マクロは 、ConnectedShapes メソッドを使用して、選択した図形への受信接続のもう一方の端にあるすべての図形の名前を検索する方法を示しています。
提供されるサンプル コード:Fred Diggs
Public Sub ConnectedShapes_Incoming_Example()
' Get the shapes that are at the other end of
' incoming connections to a selected shape
Dim vsoShape As Visio.Shape
Dim lngShapeIDs() As Long
Dim intCount As Integer
If ActiveWindow.Selection.Count = 0 Then
MsgBox ("Please select a shape that has connections.")
Exit Sub
Else
Set vsoShape = ActiveWindow.Selection(1)
End If
lngShapeIDs = vsoShape.ConnectedShapes _
(visConnectedShapesIncomingNodes, "")
Debug.Print "Shapes that are at the other end of incoming connections:"
For intCount = 0 To UBound(lngShapeIDs)
Debug.Print ActivePage.Shapes(lngShapeIDs(intCount)).Name
Next
End Sub
サポートとフィードバック
Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。