VBA 向形状添加连接点

VBA add connection points to a shape

如何向形状添加连接点?

我开始这个项目时向页面添加常规矩形并使用 AutoConnect 连接它们,效果非常好,因为每个连接都会在矩形上创建一个新的连接点。当我切换到圆角矩形时,没有创建新的连接点,连接器最终相互重叠。

我像这样添加圆角矩形...

        Application.ActiveWindow.Page.Drop Application.Documents.Item("BASIC_U.VSS").Masters.ItemU("Rounded rectangle"), 0, 0

我这样自动连接...

        Dim vsoConnectorShape As Visio.Shape
        Set vsoConnectorShape = Visio.ActivePage.Shapes("Dynamic connector")
        vsoConnectorShape.CellsU("LineColor").Formula = "rgb(" + CStr(red) + ", " + CStr(green) + ", " + CStr(blue) + ")"

        shp1.AutoConnect shp2, visAutoConnectDirNone, vsoConnectorShape

您可以通过向形状的连接点部分 (visSectionConnectionPts) 添加行来添加连接点。 代码看起来像:

Dim NewRow as Integer
NewRow = shp1.AddRow( visSectionConnectionPts , visRowLast, visTagDefault)
shp1.CellsSRC( visSectionConnectionPts, NewRow, visX).formula = "Width*0.5"
shp1.CellsSRC( visSectionConnectionPts, NewRow, visY).formula = "Height*0.5"

此代码向 shp1 添加一个新的连接点,并将该点设置在形状的中心。