当我使用VBA创建一个类似于我在工作表上绘制的矩形时,有没有连接点?添加最后一个节点后,我使用ConvertToShape。如果我对所有点使用msoEditingAuto或msoEditingCorner并不重要。只有在其中一个节点上使用SetPosition并使用现有位置时,才能使连接点可用。
答案 0 :(得分:0)
Microsoft的object reference中的以下代码给出了使用矩形连接点的示例:
Sub buildshape3()
Dim myDocument As Worksheet
Dim s As Object
Dim firstRect As Shape
Dim secondRect As Shape
Dim c As Shape
Set myDocument = Worksheets(1)
Set s = ActiveSheet.Shapes
Set firstRect = s.AddShape(msoShapeRectangle, 100, 150, 150, 150) '50, 200, 100)
firstRect.Fill.Transparency = 1
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
End Sub