Table of contents
TOC
折叠目录
展开目录

Shape.ConnectedShapes 方法 (Visio)Shape.ConnectedShapes Method (Visio)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

返回包含已连接到该形状的形状的标识符 (ID) 的数组。Returns an array that contains the identifiers (IDs) of the shapes that are connected to the shape.

语法Syntax

表达式ConnectedShapes标志CategoryFilterexpression . ConnectedShapes( Flags , CategoryFilter )

表达式_一个表示一个Shape对象的变量。_expression A variable that represents a Shape object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data Type说明Description
FlagsFlags必需RequiredVisConnectedShapesFlagsVisConnectedShapesFlags按照连接线的方向性筛选返回的形状 ID 的数组。有关可能的值,请参阅“说明”。Filters the array of returned shape IDs by the directionality of the connectors. See Remarks for possible values.
CategoryFilterCategoryFilter必需RequiredStringString通过将其限制为符合指定类别的形状的 ID 来筛选返回的形状 ID 的数组。Filters the array of returned shape IDs by limiting it to the IDs of shapes that match the specified category.

返回值Return Value

Long()Long()

注解Remarks

标志_值必须是下面的VisConnectedShapesFlags常量之一。The _Flags value must be one of the following VisConnectedShapesFlags constants.

常量ConstantValue说明Description
visConnectedShapesAllNodesvisConnectedShapesAllNodes00返回与传入和传出连接相关的形状的 ID。Return IDs of shapes that are associated with both incoming and outgoing connections.
visConnectedShapesIncomingNodesvisConnectedShapesIncomingNodes11返回与传入连接相关的形状的 ID。Return IDs of shapes that are associated with incoming connections.
visConnectedShapesOutgoingNodesvisConnectedShapesOutgoingNodes22返回与传出连接相关的形状的 ID。Return IDs of shapes that are associated with outgoing connections.

类别是用户定义的字符串,可用来对形状进行分类,从而限制容器中的成员资格。可以在形状 ShapeSheet 的 User.msvShapeCategories 单元格中定义类别。可以通过用分号分隔类别为形状定义多个类别。Categories are user-defined strings that you can use to categorize shapes and thereby to restrict membership in a container. You can define categories in the User.msvShapeCategories cell in the ShapeSheet for a shape. You can define multiple categories for a shape by separating the categories with semi-colons.

如果源对象是一维形状或主控形状的一部分, ConnectedShapes方法返回了无效的源错误。If the source object is a 1-D shape or part of a master, the ConnectedShapes method returns an Invalid Source error.

如果没有符合条件的连接的形状存在, ConnectedShapes方法将返回空数组。If no qualifying connected shapes exist, the ConnectedShapes method returns an empty array.

示例Examples

下面的 Visual Basic for Applications (VBA) 宏显示如何使用ConnectedShapes方法来查找另一端传出的连接,从所选形状的所有形状的名称。The following Visual Basic for Applications (VBA) macro shows how to use the ConnectedShapes method to find the names of all the shapes at the other end of outgoing connections from a selected shape.

示例代码提供:社区成员图标Fred DiggsSample code provided by:Community Member IconFred 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方法来查找在另一端的入站连接到所选形状的所有形状的名称。The following VBA macro shows how to use the ConnectedShapes method to find the names of all the shapes at the other end of incoming connections to a selected shape.

示例代码提供:社区成员图标Fred DiggsSample code provided by:Community Member IconFred 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
© 2018 Microsoft