如何在 Visio 2007 VBA 中向选区添加图层?
How to add layers to a selection in Visio 2007 VBA?
我想在 Visio 2007 中通过 VBA 将某些图层导出为 svg。
我无法将图层添加到选区。我该怎么做?
Sub tester()
Dim Layer As Visio.Layer
Dim Layers As Visio.Layers
Dim sel As Visio.Selection
Dim filename As String
Dim lyrName As String
Dim iLays As Integer
Set Layers = Application.ActivePage.Layers
Set sel = EmptySelection 'Or whatever empty initialization neeeds to happen...
For iLays = 1 To Layers.Count
Set Layer = Layers(iLays)
lyrName = Layer.Name
If lyrName = "Walls" Or lyrName = "Zones" Then
sel.AddLayer (lyrName) 'or some such nonsense - This is broked.
End If
filename = Application.ActiveDocument.Path & "PootyStuff.svg"
'Export the page as svg file
sel.Export filename
Next iLays
Set Layer = Nothing
Set Layers = Nothing
End Sub
试试这个代码
Sub tester()
Dim sel As Visio.Selection
Dim filename As String
ActiveWindow.DeselectAll
' create selection by layers
Set sel = ActivePage.CreateSelection(visSelTypeByLayer, visSelModeSkipSuper, "Walls;Zones")
filename = Application.ActiveDocument.Path & "PootyStuff.svg"
'Export the page as svg file
sel.Export filename
End Sub
我想在 Visio 2007 中通过 VBA 将某些图层导出为 svg。
我无法将图层添加到选区。我该怎么做?
Sub tester()
Dim Layer As Visio.Layer
Dim Layers As Visio.Layers
Dim sel As Visio.Selection
Dim filename As String
Dim lyrName As String
Dim iLays As Integer
Set Layers = Application.ActivePage.Layers
Set sel = EmptySelection 'Or whatever empty initialization neeeds to happen...
For iLays = 1 To Layers.Count
Set Layer = Layers(iLays)
lyrName = Layer.Name
If lyrName = "Walls" Or lyrName = "Zones" Then
sel.AddLayer (lyrName) 'or some such nonsense - This is broked.
End If
filename = Application.ActiveDocument.Path & "PootyStuff.svg"
'Export the page as svg file
sel.Export filename
Next iLays
Set Layer = Nothing
Set Layers = Nothing
End Sub
试试这个代码
Sub tester()
Dim sel As Visio.Selection
Dim filename As String
ActiveWindow.DeselectAll
' create selection by layers
Set sel = ActivePage.CreateSelection(visSelTypeByLayer, visSelModeSkipSuper, "Walls;Zones")
filename = Application.ActiveDocument.Path & "PootyStuff.svg"
'Export the page as svg file
sel.Export filename
End Sub