![]() |
#1
|
|||
|
|||
![]()
Hi,
I have visio 2013 and have many pages with several layers. I have 3 layers that I want to show or hide through checkboxes. In one page I created three checkmark boxes and put together some code that will either hide or show a specific layer when it's corresponding checkmark box is either checked or unchecked. It works only for that one page. I want it to work on all pages in the document. As you can see below, I have it as three separate pieces of code but if there's a better way to combine it into one piece of code please feel free to mash it into one. My code is: Public Sub CheckBox1_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 = "To Be Form" Then Set LayerCellObj = LayerObj.CellsC(visLayerVisible) If CheckBox1.Value Then LayerCellObj.Formula = True Or 1 Else LayerCellObj.Formula = False Or 0 End If End If Next End Sub Public Sub CheckBox2_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 = "SHC As Is Form" Then Set LayerCellObj = LayerObj.CellsC(visLayerVisible) If CheckBox2.Value Then LayerCellObj.Formula = True Or 1 Else LayerCellObj.Formula = False Or 0 End If End If Next End Sub Public Sub CheckBox3_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 = "Works As Is Form" Then Set LayerCellObj = LayerObj.CellsC(visLayerVisible) If CheckBox3.Value Then LayerCellObj.Formula = True Or 1 Else LayerCellObj.Formula = False Or 0 End If End If Next End Sub I've attached a sample of the document too. Thanks |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with show/hide content control | acontreras | Word VBA | 0 | 10-21-2014 07:28 PM |
![]() |
Lowenburg | Word | 3 | 02-01-2012 03:57 PM |
![]() |
trintukaz | Word | 3 | 12-29-2011 12:23 AM |
![]() |
ccordner | Word VBA | 2 | 07-04-2011 03:00 AM |
VBA to show/hide tables | ccordner | Outlook | 0 | 07-01-2011 05:10 AM |