Layers menu

Started by raven7, March 03, 2015, 05:40:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

raven7

Hello,

I'm looking for some Visio support. I'm sure it is the right place to ask. I need to do following 5 layers. 1 of them is background.

4 buttons showing/hiding all upper layers. The problem is that when I click one of the buttons I want all of the layers except background to be hidden and then desired one to be displayed.


Is it possible?

I'm using command buttons with following code:



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
Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
If LayerName = "Metro-1" Then
' Debug.Print LayerName
If LayerCellObj.Formula = False Then

LayerCellObj.Formula = True

Else
LayerCellObj.Formula = False
End If
End If
Next

End Sub


Private Sub CommandButton2_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
Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
If LayerName = "Metro-2" Then
' Debug.Print LayerName
If LayerCellObj.Formula = False Then

LayerCellObj.Formula = True

Else
LayerCellObj.Formula = False
End If
End If
Next

End Sub




[/code]

Yacine

Hi Raven,
Where is the problem? You have already all you need to fulfill the task.
Either you add a nested IF statement (if layer is background than true ELSE switch layer state), or you change your logic to a SELECT CASE loop (case background: layer = true, case THISANDTAHAT: do something else).


HTH,
Y.
Yacine

raven7

Hi,

It is working. Thanks.