• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5053
  • Last Modified:

Toggle Visio Layers On and Off

I have 4 buttons(Commandbutton1. Commandbutton2, etc...) and 4 layers(Layer1, Layer2, etc..). I would like to use the buttons to toggle the visibility on and off pending on current visibility state.

Psuedo code:
sub Commandbutton1_Click:
----if layer1 is visible then:
--------layer1.visible = 0
----else
--------layer1.visible = 1
----end if
end sub
1
m_travis
Asked:
m_travis
  • 5
  • 4
2 Solutions
 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
A very similar question came up here once before and I still have the code that solved that problem. Please take a look and let me know if you need something different.
Determine-which-of-four-shapes-was-click
0
 
m_travisAuthor Commented:
what is the file type?
0
 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
Very strange... it is a Visio diagram (.vsd) but it appears that the EE upload truncated the name -- including the file extension! Just rename the file and add .vsd to the  end and you should be all set.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
m_travisAuthor Commented:
Here was my solution, some of the code was taken from Scott:
Private Sub CommandButton1_Click()
    If CommandButton1.Data1 = True Then
        'Turn Layer Off
        TurnLayerOff ("Inbound Mail")
        CommandButton1.Data1 = False
    Else
        'Turn Layer On
        TurnLayerOn ("Inbound Mail")
        CommandButton1.Data1 = True
    End If
End Sub

Private Sub CommandButton2_Click()
    If CommandButton2.Data1 = True Then
        'Turn Layer Off
        TurnLayerOff ("Outbound Mail")
        CommandButton2.Data1 = False
    Else
        'Turn Layer On
        TurnLayerOn ("Outbound Mail")
        CommandButton2.Data1 = True
    End If
End Sub

Private Sub CommandButton3_Click()
    If CommandButton3.Data1 = True Then
        'Turn Layer Off
        TurnLayerOff ("Retrieve Mail")
        CommandButton3.Data1 = False
    Else
        'Turn Layer On
        TurnLayerOn ("Retrieve Mail")
        CommandButton3.Data1 = True
    End If
End Sub

Private Sub CommandButton4_Click()
    If CommandButton4.Data1 = True Then
        'Turn Layer Off
        TurnLayerOff ("Replication")
        CommandButton4.Data1 = False
    Else
        'Turn Layer On
        TurnLayerOn ("Replication")
        CommandButton4.Data1 = True
    End If
End Sub

Function TurnLayerOff(x As String)
    Dim pg As Visio.Page
    Dim lyrTarget As Visio.Layer
    
    value = True
    Set pg = ActivePage
    Set lyrTarget = pg.Layers(x)
    lyrTarget.CellsC(visLayerVisible).Formula = 0
    
End Function

Function TurnLayerOn(x As String)
    Dim pg As Visio.Page
    Dim lyrTarget As Visio.Layer
    Dim value As Boolean
    
    value = True
    Set pg = ActivePage
    Set lyrTarget = pg.Layers(x)
    lyrTarget.CellsC(visLayerVisible).Formula = 1
    
End Function

Open in new window

0
 
m_travisAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for m_travis's comment #a40748526
Assisted answer: 300 points for scott's comment #a40747166

for the following reason:

My solution solved my problem. The other solution just contributed to the solution.
0
 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
I'm glad my code provided some assistance, and thanks for posting your final code for the benefit of others.

Now I have a question: did you intend to close this question or accept your answer and mine? There is a difference at EE -- closing the question makes it go away, but accepting one or more answers leaves it here for others to learn from. If you intended the latter, use the "accept answers" links instead.

Thanks...
0
 
m_travisAuthor Commented:
I wanted to provide you credit for helping and accept your answer with mine to make the questioned answered. All i did was hit "Accept Multiple Solutions", select the answers, and submit. Is that the wrong process to follow?
0
 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
No, that sounds correct, but for some reason the email I received said that you'd made a request to cancel the question.

Go ahead and try it again and I'll let it go either way. Thanks.
0
 
m_travisAuthor Commented:
My solution solved my problem. The other solution just contributed to the solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now