Consulting

Results 1 to 6 of 6

Thread: Buttons to hide and show Visio Layers

  1. #1
    VBAX Newbie
    Joined
    May 2014
    Posts
    3
    Location

    Buttons to hide and show Visio Layers

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    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
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    May 2014
    Posts
    3
    Location
    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!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    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?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Newbie
    Joined
    May 2014
    Posts
    3
    Location
    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
    Attached Images Attached Images

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    A picture is interesting, but of no help.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •