Visio VBA将动态连接器连接到连接点



我在连接链接的动态连接器时遇到了一些麻烦,该连接器实际上连接到预定义的连接点,而不是仅连接到顶部。

我的主人在左侧有一些文本框,右侧有一些文本框。当我自动连接到这些文本框时,它们都可以连接到第一个和最后一个,除了第一个和最后一个。与其像其他侧面连接到侧面的顶部和底部那样连接到侧面的侧面,这会破坏视觉效果。即使在侧面定义了一个连接点。

我一直在考虑使用Glueto手动连接到连接点,但我不知道如何向连接点进行调整。

Set vsoConnectorShape = ActiveDocument.Masters.ItemU("Dynamic connector")
Set BoxShape = ActivePage.Shapes(i)
Set DevShape = ActivePage.Shapes(j)
NewRow = DevShape.AddRow(visSectionConnectionPts, visRowLast, visTagDefault)
DevShape.CellsSRC(visSectionConnectionPts, NewRow, visX).Formula = "Width*0"
DevShape.CellsSRC(visSectionConnectionPts, NewRow, visY).Formula = "Height*0.5"
DevShape.AutoConnect BoxShape, visAutoConnectDirLeft, vsoConnectorShape

所以我的实际问题是如何连接到连接点而不是形状本身?

您可以粘合连接器的.Cells("BeginX").Cells("EndX")

  1. 到一个形状的最近连接器:Shape.Cells("PinX")
  2. 或到选定的连接器:Shape.CellsSRC(visSectionConnectionPts, row, column)

  • 可用连接点的数量取决于您的形状类型
  • 如果单击形状并按正确的Mouseclick打开其ShapeSheet,则会找到"连接点"部分。该表的每一行代表一个连接点 - 单击表中的行,看看您的图纸中选择了哪个。
    使用以CellSRC的0开头的行号
    列号不相关,可以为0或1 = viscnnctx或viscnncty

  • 另外,只需与宏录音机捕获手动连接
    并在代码中搜索e。g。
    CellSRC(7, 0, 0) 7 = vissectionConnectionpts,0 = 1st连接点,0


Dim myConnector As Visio.Shape
' drop it somewhere
Set myConnector = ActiveWindow.Page.Drop(Application.ConnectorToolDataObject, 1, 10)
' connect it to the nearest connection point of a shape (varies if you drag)
myConnector.Cells("BeginX").GlueTo BoxShape.Cells("PinX")
' connect it a fixed connection point (example if shape has 4 points)
myconnector.Cells("BeginX").GlueTo _
    Boxshape.CellsSRC(visSectionConnectionPts, 0, 0)  ' left                  
' .CellsSRC(visSectionConnectionPts, 1, 0)  ' right
' .CellsSRC(visSectionConnectionPts, 2, 0)  ' top
' .CellsSRC(visSectionConnectionPts, 3, 0)  ' bottom

最新更新