vba - Visio vba 将动态连接器连接到连接点

标签 vba visio

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

我的主人在左侧有一些文本框,在右侧有一些文本框。当我自动连接到这些文本框时,除了第一个和最后一个之外,它们都连接正常。它们不像其他连接到侧面,而是连接到盒子中间的顶部和底部,这破坏了视觉效果。即使侧面定义了一个连接点。

我一直在考虑使用 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)

  • 可用连接点的数量取决于您的形状类型
  • 如果单击该形状并通过单击鼠标右键打开其 ShapeSheet,您将找到“连接点”部分。该表的每一行代表一个连接点 - 单击表中的行并查看在绘图中选择了哪个连接点。
    CellSRC 使用以 0 开头的行号
    列号不相关,可以是 0 或 1 = visCnnctX 或 visCnnctY

  • 或者只需手动连接宏记录器
    并在代码中搜索 e。 g.
    CellSRC(7, 0, 0) 7 = visSectionConnectionPts, 0 = 第一个连接点, 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

关于vba - Visio vba 将动态连接器连接到连接点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54986245/

相关文章:

VBA Microsoft Visio 文档操作,无需打开应用程序

C# Visio Interop,未调用事件处理程序

VBA代码按列名称、不同位置对多列进行排序

excel - 使用 ACCESS vba 中的日期变量从另一个调用子程序

excel - vba搜索替换字符

c++ - Visio & UML - 在属性和返回值中显示指针

visio - 如何在Visio 2007中绘制ER图?

vba - 运行时错误 13,类型不匹配 MsgBox 取消

excel - 选择具有相似值的单元格,然后按时间顺序重命名文本

azure - 如何使用Visio绘制Kusto的应用程序架构图?