Hi all,
I have the following code which is looking to use a Toggle Button to show / hide a Layer in Visio (I know this is an Excel forum but hopefully the VBA skills are transferable and you can help)...
The button seems to hide the Layer but when clicked again the layer does not re-appear. Does anyone know why?
Thanks.
Private Sub CommandButton1_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 = "TEST" Then
Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
If CommandButton1.Value Then
LayerCellObj.Formula = True Or 1
Else
LayerCellObj.Formula = False Or 0
End If
End If
Next
End Sub
I have the following code which is looking to use a Toggle Button to show / hide a Layer in Visio (I know this is an Excel forum but hopefully the VBA skills are transferable and you can help)...
The button seems to hide the Layer but when clicked again the layer does not re-appear. Does anyone know why?
Thanks.
Private Sub CommandButton1_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 = "TEST" Then
Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
If CommandButton1.Value Then
LayerCellObj.Formula = True Or 1
Else
LayerCellObj.Formula = False Or 0
End If
End If
Next
End Sub