Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-03-2018, 04:33 PM
ivano ivano is offline show or hide layers in all pages Windows 10 show or hide layers in all pages Office 2013
Novice
show or hide layers in all pages
 
Join Date: Dec 2018
Posts: 3
ivano is on a distinguished road
Default show or hide layers in all pages

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with show/hide content control acontreras Word VBA 0 10-21-2014 07:28 PM
show or hide layers in all pages Tab symbols display with Show/Hide off Lowenburg Word 3 02-01-2012 03:57 PM
show or hide layers in all pages Show Hide info trintukaz Word 3 12-29-2011 12:23 AM
show or hide layers in all pages VBA to show/hide tables ccordner Word VBA 2 07-04-2011 03:00 AM
VBA to show/hide tables ccordner Outlook 0 07-01-2011 05:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:15 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft