Table of contents

ShapeRange.RerouteConnections 方法 (PowerPoint)ShapeRange.RerouteConnections Method (PowerPoint)

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

重置连接符,使它们可以采用最短的路径连接的形状。若要执行此操作, RerouteConnections方法可能会分离接头两端并将它们重新连接到已连接的形状上的不同连接站点。Reroutes connectors so that they take the shortest possible path between the shapes they connect. To do this, the RerouteConnections method may detach the ends of a connector and reattach them to different connecting sites on the connected shapes.


表达式RerouteConnectionsexpression. RerouteConnections

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


此方法将重排连接在指定形状上的所有连接符;如果指定的形状是连接符,会重排该连接符。This method reroutes all connectors attached to the specified shape; if the specified shape is a connector, it is rerouted.

如果该方法应用于一个连接符,则只重置该连接符;如果该方法应用于一个已连接的形状,则重置该形状上所有的连接符。If this method is applied to a connector, only that connector will be rerouted. If this method is applied to a connected shape, all connectors to that shape will be rerouted.


本示例将两个矩形添加myDocument,并用弯曲的连接符将它们连接起来,以便所需最短的路径的两个矩形,然后重排连接符。注意RerouteConnections方法调整大小和位置,并确定哪个连接网站它附着,因此最初指定值与BeginConnect使用 ConnectionSite 参数和EndConnect方法是无关紧要的。This example adds two rectangles to myDocument, connects them with a curved connector, and then reroutes the connector so that it takes the shortest possible path between the two rectangles. Note that the RerouteConnections method adjusts the size and position of the connector and determines which connecting sites it attaches to, so the values you initially specify for the ConnectionSite arguments used with the BeginConnect and EndConnect methods are irrelevant.

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)
Set newConnector = s _
    .AddConnector(msoConnectorCurve, 0, 0, 100, 100)

With newConnector.ConnectorFormat
    .BeginConnect firstRect, 1
    .EndConnect secondRect, 1
End With


另请参阅See also


绘图对象ShapeRange Object

© 2018 Microsoft