获取连接层
Get layer of connector
我可以在 vba 中获取连接器分配到的层的名称吗?
我正在用这样的形状来做这个
ActivePage.Shapes(1).layer(1)
现在我正在寻找类似的东西,但用于连接器。
我不是很清楚你的问题,但连接器没有什么特别的 - 它们仍然只是形状。因此,如果您知道目标形状和图层的索引,则可以使用上面的代码。
Visio 中的形状也可以属于多个图层(图层的工作方式与 Photoshop 不同),因此您可能希望先获取图层数,然后 运行 遍历每个图层一。例如:
Sub CheckLayers()
Dim shp As Visio.Shape
Dim i As Integer
For Each shp In ActivePage.Shapes
Debug.Print shp.NameU
For i = 1 To shp.LayerCount
Debug.Print " " & shp.Layer(i).Name
Next i
Debug.Print ""
Next shp
End Sub
此外,根据您要执行的操作,您可能希望利用 Page.CreateSelection method 到 return 基于特定图层上的形状的选择。这是对 Visio SDK 稍作修改的版本:
Public Sub CreateSelection_Layer_Example()
Dim vsoLayer As Visio.Layer
Dim vsoSelection As Visio.Selection
Set vsoLayer = ActivePage.Layers.ItemU("Connector")
Set vsoSelection = ActivePage.CreateSelection(visSelTypeByLayer, visSelModeSkipSuper, vsoLayer)
'Note that you don't have to pass the selection object to
'the ActiveWindow Selection property - you can just work
'with it directly if you want to
Application.ActiveWindow.Selection = vsoSelection
End Sub
如果您使用的是 动态连接器,它会自动分配给名为 'Connector'.
的图层
我可以在 vba 中获取连接器分配到的层的名称吗?
我正在用这样的形状来做这个
ActivePage.Shapes(1).layer(1)
现在我正在寻找类似的东西,但用于连接器。
我不是很清楚你的问题,但连接器没有什么特别的 - 它们仍然只是形状。因此,如果您知道目标形状和图层的索引,则可以使用上面的代码。
Visio 中的形状也可以属于多个图层(图层的工作方式与 Photoshop 不同),因此您可能希望先获取图层数,然后 运行 遍历每个图层一。例如:
Sub CheckLayers()
Dim shp As Visio.Shape
Dim i As Integer
For Each shp In ActivePage.Shapes
Debug.Print shp.NameU
For i = 1 To shp.LayerCount
Debug.Print " " & shp.Layer(i).Name
Next i
Debug.Print ""
Next shp
End Sub
此外,根据您要执行的操作,您可能希望利用 Page.CreateSelection method 到 return 基于特定图层上的形状的选择。这是对 Visio SDK 稍作修改的版本:
Public Sub CreateSelection_Layer_Example()
Dim vsoLayer As Visio.Layer
Dim vsoSelection As Visio.Selection
Set vsoLayer = ActivePage.Layers.ItemU("Connector")
Set vsoSelection = ActivePage.CreateSelection(visSelTypeByLayer, visSelModeSkipSuper, vsoLayer)
'Note that you don't have to pass the selection object to
'the ActiveWindow Selection property - you can just work
'with it directly if you want to
Application.ActiveWindow.Selection = vsoSelection
End Sub
如果您使用的是 动态连接器,它会自动分配给名为 'Connector'.
的图层