将指定连接符的终点连到指定形状上。如果该连接符的终点已经连接到另一个形状,则断开原连接;如果该连接符终点没有位于指定的连接位置,此方法将它移到该位置,并调整连接符的位置和大小。使用 BeginConnect 方法将连接符的起点连到形状上。
expression.EndConnect(ConnectedShape, ConnectionSite)
expression 必选。该表达式返回一个 ConnectorFormat 对象。
ConnectedShape 必选。Shape 对象。要将连接符终点连到的形状。指定的 Shape 对象必须与该连接符处在相同的 Shapes 集合。
ConnectionSite 必选。Long 类型。由 ConnectedShape 指定的形状上的连接位置。必须是从 1 到某固定值间的整数,该固定值由指定形状的 ConnectionSiteCount 属性返回。如果要连接符自动查找两个形状间的最短路径,请为此参数指定任何有效整数值,并在连接符的两端都连到形状之后使用 RerouteConnections 方法。
连接符附着到一个对象后,如有必要,它的大小和位置会自动调整。
本示例向当前演示文稿的第一张幻灯片中添加两个矩形框,并用曲线连接符连接它们。注意,RerouteConnections 方法使得应用在 ConnectionSite 参数中的值与 BeginConnect 和 EndConnect 方法无关。
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