本示例将两个矩形添加到 myDocument,用曲线连接符连接两个矩形,然后重置连接符使两个矩形间采用最短的路径。请注意,RerouteConnections 方法用于调整连接符的大小和位置并决定要连接到哪个连接位置,因此最初为 ConnectionSite 参数指定与 BeginConnect 和 EndConnect 方法一起使用的值是不相关的。

Set myDocument = ActivePresentation.Slides(1)
Set s = myDocument.Shapes
Set firstRect = s.AddShape(ksoShapeRectangle, 100, 50, 200, 100)
Set secondRect = s.AddShape(ksoShapeRectangle, 300, 300, 200, 100)
Set newConnector = s _
    .AddConnector(ksoConnectorCurve, 0, 0, 100, 100)
With newConnector.ConnectorFormat
    .BeginConnect firstRect, 1
    .EndConnect secondRect, 1
End With
newConnector.RerouteConnections