调整连接符,使之以最短的路径连接两个图形。为达到这一目的,RerouteConnections 方法可能会将连接符的端点连接到相应图形的其他连接点上。
本方法将调整连接在指定图形上的所有连接符;如果指定的图形是连接符,就调整该连接符。
expression.RerouteConnections
expression 必需。该表达式返回一个 Shape 或 ShapeRange 对象。
如果本方法应用于连接符,那么就只重新设置该连接符。如果本方法应用于用连接符连接的图形,那么就将重新设置连接在该图形上的所有连接符。
本示例向 myDocument
中添加了两个矩形,并用弯曲的连接符将这两个矩形连接起来,然后重新设置该连接符,使之以最短的路径来连接相应的矩形。请注意,因为 RerouteConnections 方法将改变连接符的位置和尺寸,并决定连接到哪个连接点上,所以在 BeginConnect 方法和 EndConnect 方法中所指定的 ConnectionSite 参数变得无关紧要。
Set myDocument = Worksheets(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
newConnector.RerouteConnections