PDA

View Full Version : [SLEEPER:] Buttons to hide and show Visio Layers



de049
05-14-2014, 08:14 AM
Hi all,

this is my first post. thanks for having me.

I have a Visio 2013 file with quite a few layers. I have made a few buttons and labelled these as per the layer names. I now want to be able to have each of these buttons hide the corresponding layer when the button is clicked. At the same time that a button reveals a layer, any other layer will be hidden, so only one layer is shown at a given time.

Besides these interchangeable layers, I have a base layer that is locked and would remain on the screen at all times. so when hiding other layers this particular 'base' layer must remain active.

Hope someone can help.

many thanks!!

Dwayne

Bob Phillips
05-14-2014, 09:02 AM
Try this, just call it with the target layer name


Public Sub HideThisLayer(ByRef LayerName As String)
Dim pag As Visio.Page
Dim lyr As Visio.Layer
Dim aryLayer() As String
Dim sLayer As String
Dim iLayer As Integer
Set pag = ActivePage
For Each lyr In pag.Layers
lyr.CellsC(Visio.visLayerVisible).Formula = UCase(lyr.Name) = UCase(LayerName)
Next lyr
End Sub

de049
05-15-2014, 01:04 AM
Hi,

thanks for the response. I am slightly confused. Which parameter do I replace with the actual layer name(s). At present, if I associate this code to an 'onClick' behaviour, all layers are removed (including the locked base layer). I would like each button to reveal its designated layer and at the same time remove the other layer that was active (but keeping the locked background layer in place at all times.

To give you more info on what I am trying to achieve, I am preparing a map to show all my travel locations, so the actual map is to always remain visible, while each button would reveal the routes i've taken on each of my travels. Each route represented by a layer.

thanks!

Bob Phillips
05-15-2014, 01:35 AM
In the event code for each commandbutton, you would call this routine, for instance


Call HideThisLayer(CommandButton1.Caption)

ANy chance of posting your document to see what is happening?

de049
05-15-2014, 03:44 AM
Hi xld,

apologies but my knowledge of VBA is not enough to allow me to fully understand this. Find attached an image what I am working on. the actual Visio file was too large to upload. this should help to better understand my requirement. Each button should show the associated route (coloured line) on the map, while at the same time hiding any other routes that are visible (so only one layer is visible at a time (the base layer map must remain locked and visible at all times). Presently all 3 layers (routes) are being shown. you will see I have made a button for each layer at the top of the image. each coloured line should be attributed to a button.

thanks

Bob Phillips
05-15-2014, 03:49 AM
A picture is interesting, but of no help.