Это мой первый ответ на stackoverflow, и я надеюсь, что следующий код VBA может решить вашу проблему с тем, как выделить соединители или связанные фигуры в Visio!
Public Sub HighlightConnectedShapes()
Dim vsoShape As Visio.Shape
Dim connectedShapeIDs() As Long
Dim connectorIDs() As Long
Dim intCount As Integer
' Highlight the selected shape
Set vsoShape = ActiveWindow.Selection(1)
vsoShape.CellsU("Fillforegnd").FormulaU = "RGB(146, 212, 0)"
vsoShape.Cells("LineColor").FormulaU = "RGB(168,0,0)"
vsoShape.Cells("LineWeight").Formula = "2.5 pt"
' Highlight connectors from/to the selected shape
connectorIDs = vsoShape.GluedShapes _
(visGluedShapesAll1D, "")
For intCount = 0 To UBound(connectorIDs)
ActivePage.Shapes.ItemFromID(connectorIDs(intCount)).Cells("LineColor").FormulaU = "RGB(168,0,0)"
ActivePage.Shapes.ItemFromID(connectorIDs(intCount)).Cells("LineWeight").Formula = "2.5 pt"
Next
' Highlight shapes that are connected to the selected shape
connectedShapeIDs = vsoShape.connectedShapes(visConnectedShapesAllNodes, "")
For intCount = 0 To UBound(connectedShapeIDs)
ActivePage.Shapes.ItemFromID(connectedShapeIDs(intCount)).Cells("LineColor").FormulaU = "RGB(168,0,0)"
ActivePage.Shapes.ItemFromID(connectedShapeIDs(intCount)).Cells("LineWeight").Formula = "2.5 pt"
Next
End Sub
Чтобы запустить макрос, вы можете рассмотреть возможность его ассоциированияс поведением двойного щелчка фигур.
Если вам нужно только выделить входящие / исходящие соединители и входящие / исходящие формы, замените visGluedShapesAll1D
на visGluedShapesIncoming1D
/ visGluedShapesOutgoing1D
и visConnectedShapesAllNodes
с visConnectedShapesIncomingNodes
/ visConnectedShapesOutgoingNodes
.
Узнайте больше на visgluedshapesflags и visconnectedshapesflags .Удачи!