EndConnect 方法 (Excel) ConnectorFormatConnectorFormat.EndConnect method (Excel)

将指定连接线的末端附加到指定形状。Attaches the end of the specified connector to a specified shape. 如果已存在的连接符的终点与另一个形状之间的连接,该连接会断开。If there's already a connection between the end of the connector and another shape, that connection is broken.

如果连接符的终点没有位于指定的连接位置,此方法将连接符的终点移到该连接结点,并调整连接符的位置和大小。If the end of the connector isn't already positioned at the specified connecting site, this method moves the end of the connector to the connecting site and adjusts the size and position of the connector.

使用 BeginConnect 方法可将连接符的起点连接到形状。Use the BeginConnect method to attach the beginning of the connector to a shape.

语法Syntax

表达式EndConnect(ConnectedShape, ConnectionSite)expression.EndConnect (ConnectedShape, ConnectionSite)

_表达式_一个代表**ConnectorFormat** 对象的变量。expression A variable that represents a ConnectorFormat object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
ConnectedShapeConnectedShape 必需Required ShapeShape 要连接到连接符的终点的形状。The shape to attach the end of the connector to. 指定的 形状 对象必须是同一与连接器的 Shapes 集合中。The specified Shape object must be in the same Shapes collection as the connector.
ConnectionSiteConnectionSite 必需Required LongLong 必须是 1 到指定形状的 ConnectionSiteCount 属性返回的整数之间的整数。Must be an integer between 1 and the integer returned by the ConnectionSiteCount property of the specified shape. 如果您想要自动查找最短的路径连接两个形状之间的连接器,指定该参数的任何有效的整数,并将 RerouteConnections 方法后连接器附着在两端的形状。If you want the connector to automatically find the shortest path between the two shapes it connects, specify any valid integer for this argument and then use the RerouteConnections method after the connector is attached to shapes at both ends.

说明Remarks

将连接符连接到某个对象以后,该连接符的大小和位置将在必要时进行自动调整。When you attach a connector to an object, the size and position of the connector are automatically adjusted, if necessary.

示例Example

本示例向_myDocument_中添加两个矩形, 并用曲线连接符将它们连接起来。This example adds two rectangles to myDocument and connects them with a curved connector. 请注意,对 RerouteConnections 方法的调用使得在 BeginConnect 方法和 EndConnect 方法中所指定的 ConnectionSite 参数值不相关联。Notice that the RerouteConnections method makes it irrelevant what values you supply for the ConnectionSite arguments used with the BeginConnect and EndConnect methods.

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 c = s.AddConnector(msoConnectorCurve, 0, 0, 100, 100) 
With c.ConnectorFormat 
 .BeginConnect ConnectedShape:=firstRect, ConnectionSite:=1 
 .EndConnect ConnectedShape:=secondRect, ConnectionSite:=1 
 c.RerouteConnections 
End With

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.