Author Topic: Layers menu  (Read 5601 times)

0 Members and 1 Guest are viewing this topic.

raven7

  • Newbie
  • *
  • Posts: 2
Layers menu
« on: March 03, 2015, 12:40:02 PM »
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:

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

  • Hero Member
  • *****
  • Posts: 3210
Re: Layers menu
« Reply #1 on: March 03, 2015, 01:08:03 PM »
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

  • Newbie
  • *
  • Posts: 2
Re: Layers menu
« Reply #2 on: March 03, 2015, 03:23:16 PM »
Hi,

It is working. Thanks.