ConnectorFormat.BeginConnect 方法 (Publisher)

将指定连接线的始端附加到指定形状。

语法

表达式BeginConnect (ConnectedShapeConnectionSite)

表达 一个代表 ConnectorFormat 对象的变量。

参数

名称 必需/可选 数据类型 说明
ConnectedShape 必需 Shape Publisher 将连接符的起点连接的形状。 指定的 形状 对象必须是同一与连接器的 Shapes 集合中。
ConnectionSite 必需 Long ConnectedShape 指定的形状上的连接站点。 必须是 1 到指定形状的 ConnectionSiteCount 属性返回的整数之间的整数。

连接结点进行编号从指定形状的顶部开始并按逆时针的形状周围。 如果您想要自动查找最短的路径连接两个形状之间的连接器,指定该参数的任何有效的整数,并将 RerouteConnections 方法后连接器附着在两端的形状。

备注

如果已存在的连接符的起点与其他形状之间的连接,该连接会断开。 如果连接符的起点没有位于指定的连接位置,该方法会将连接符的起点移动到连接位置并调整连接符的大小和位置。

将连接符连接到对象后,如有必要,连接符的大小和位置会自动调整。

使用 EndConnect 方法可将连接符的终点连接到形状。

示例

以下示例将两个矩形添加到当前出版物的第一页,并用曲线连接符将它们连接起来。 请注意,RerouteConnections 方法将替代为 BeginConnectEndConnect 方法一起使用的 ConnectionSite 参数提供的值。

Dim shpRect1 As Shape 
Dim shpRect2 As Shape 
 
With ActiveDocument.Pages(1).Shapes 
 
 ' Add two new rectangles. 
 Set shpRect1 = .AddShape(Type:=msoShapeRectangle, _ 
 Left:=100, Top:=50, Width:=200, Height:=100) 
 Set shpRect2 = .AddShape(Type:=msoShapeRectangle, _ 
 Left:=300, Top:=300, Width:=200, Height:=100) 
 
 ' Add a new curved connector. 
 With .AddConnector(Type:=msoConnectorCurve, _ 
 BeginX:=0, BeginY:=0, EndX:=100, EndY:=100) _ 
 .ConnectorFormat 
 
 ' Connect the new connector to the two rectangles. 
 .BeginConnect ConnectedShape:=shpRect1, ConnectionSite:=1 
 .EndConnect ConnectedShape:=shpRect2, ConnectionSite:=1 
 
 ' Reroute the connector to create the shortest path. 
 .Parent.RerouteConnections 
 End With 
 
End With 

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。