Hi All
Apologies if this is the incorrect forum
I am creating layers within my diagram with no problems, what i can't seem to get functioning is that i have multiple toggle buttons to the layers to display them. What happens is i want to view button 3 layer but this wont display unless i view button 1 and 2
Is there something i am doing wrong here? I am pretty new to this and have very basic VBA code. The code i am using is: -
Private Sub ToggleButton1_Click()
Dim LayersObj As Visio.Layers
Dim LayerObj As Visio.Layer
Dim LayerName As String
Dim LayerCellObj As Visio.Cell
Set LayersObj = ActivePage.Layers
For Each LayerObj In LayersObj
LayerName = LayerObj.Name
If LayerName = "Layer1" Then
Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
If ToggleButton1.Value Then
LayerCellObj.Formula = True Or 1
Else
LayerCellObj.Formula = False Or 0
End If
End If
Next
End Sub
In addition, what would be good would also be able to have a button to toggle all on/off (display/hide) the layers
Thanks
Code has some syntax errors.
I swapped out your toggle button for simple test as proof of concept.
Sub Macro1()
Dim LayersObj As Visio.Layers
Dim LayerObj As Visio.Layer
Dim LayerName As String
Dim layVis As Boolean
' Set vsoLayer1 = ActivePage.Layers.Item("Yellow")
' vsoLayer1.CellsC(visLayerVisible).FormulaU = "0"
Set LayersObj = ActivePage.Layers
For Each LayerObj In LayersObj
LayerName = LayerObj.Name
If LayerName = "Yellow" Then
layVis = LayerObj.CellsC(visLayerVisible).ResultStr(visNone)
' If ToggleButton1.Value Then
If layVis = "0" Then 'replace this line with the above (uncomment)
LayerObj.CellsC(visLayerVisible).FormulaU = "1"
Else
LayerObj.CellsC(visLayerVisible).FormulaU = "0"
End If
End If
Next
End Sub
Hi wapperdude
Thanks for the above
I tried the below and i couldn't get it to work. Sorry, sort of new to this. I went into Developer > View Code > Toggle Button 2 and amended to the below but when i clicked the button, nothing appeared or dissapeared
Thanks