BeginConnect 方法

       

将指定连接符的起点附加到指定形状。如果该连接符的起点已经连接到另一个形状,则断开原连接;如果该连接符起点没有位于指定的连接位置,此方法将它移到该位置,并调整连接符的大小和位置。使用 EndConnect 方法将连接符的终点附加到形状。

expression.BeginConnect(ConnectedShape, ConnectionSite)

expression  必选。该表达式返回一个 ConnectorFormat 对象。

ConnectedShape   必选。Shape 对象。将连接符起点附加到的形状。指定的 Shape 对象必须与该连接符在同一 Shapes 集合内。

ConnectionSite  必选。Long 类型。由 ConnectedShape 指定的形状上的连接位置。必须是从 1 到指定形状的 ConnectionSiteCount 属性返回值之间的一个整数。如果要连接符自动选取两个形状间的最短路径,请为此参数指定任何有效整数值,并在连接符的两端都连到形状之后使用 RerouteConnections 方法。

说明

将连接符附加到对象后,如有必要,会自动调整该连接符的大小和位置。

示例

本示例将两个矩形框添加到活动演示文稿第一张幻灯片,并用曲线连接符将它们连接。请注意 RerouteConnections 方法使应用于 ConnectionSite 参数的值与 BeginConnectEndConnect 方法无关。

Set myDocument = ActivePresentation.Slides(1)
Set s = myDocument.Shapes
Set firstRect = s.AddShape(msoShapeRectangle, 100, 50, 200, 100)
Set secondRect = s.AddShape(msoShapeRectangle, 300, 300, 200, 100)
With s.AddConnector(msoConnectorCurve, 0, 0, 100, 100) _
        .ConnectorFormat
    .BeginConnect ConnectedShape:=firstRect, ConnectionSite:=1
    .EndConnect ConnectedShape:=secondRect, ConnectionSite:=1
    .Parent.RerouteConnections
End With