News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Layers and Displaying Layers

Started by Steveak, July 31, 2019, 03:56:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Steveak

Hi All

Apologies if this is the incorrect forum

I am creating layers within my diagram with no problems, what i can't seem to get functioning is that i have multiple toggle buttons to the layers to display them. What happens is i want to view button 3 layer but this wont display unless i view button 1 and 2

Is there something i am doing wrong here? I am pretty new to this and have very basic VBA code. The code i am using is: -

Private Sub ToggleButton1_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
        If LayerName = "Layer1" Then
            Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
            If ToggleButton1.Value Then
                LayerCellObj.Formula = True Or 1
            Else
                LayerCellObj.Formula = False Or 0
            End If
        End If
    Next
End Sub

In addition, what would be good would also be able to have a button to toggle all on/off (display/hide) the layers

Thanks

wapperdude

Code has some syntax errors.

I swapped out your toggle button for simple test as proof of concept.

Sub Macro1()

    Dim LayersObj As Visio.Layers
    Dim LayerObj As Visio.Layer
    Dim LayerName As String
    Dim layVis As Boolean
   
'    Set vsoLayer1 = ActivePage.Layers.Item("Yellow")
'    vsoLayer1.CellsC(visLayerVisible).FormulaU = "0"


    Set LayersObj = ActivePage.Layers
        For Each LayerObj In LayersObj
            LayerName = LayerObj.Name
            If LayerName = "Yellow" Then
                layVis = LayerObj.CellsC(visLayerVisible).ResultStr(visNone)
'                If ToggleButton1.Value Then
                If layVis = "0" Then           'replace this line with the above (uncomment)
                    LayerObj.CellsC(visLayerVisible).FormulaU = "1"
                Else
                    LayerObj.CellsC(visLayerVisible).FormulaU = "0"
                End If
            End If
        Next
End Sub


Visio 2019 Pro

Steveak

Hi wapperdude

Thanks for the above

I tried the below and i couldn't get it to work. Sorry, sort of new to this. I went into Developer > View Code > Toggle Button 2 and amended to the below but when i clicked the button, nothing appeared or dissapeared

Thanks

Browser ID: smf (is_webkit)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 170 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1067KB.
Tokens: post-login.
Cache hits: 12: 0.00119s for 26,766 bytes (show)
Cache misses: 1: (show)
Queries used: 15.

[Show Queries]