Set layer visibility on all pages in a Visio 2000 SR1 document

M

M. Warnier

Hi all,

I want to be able to control layer visibility on all pages in a Visio
drawing.
On the first page, I want to have checkboxes (MS Forms 2.0) to select
which layers should be visible and not. However, this only works for
the page on which the checkbox resides. On the other pages, the
shapesheet cells are updated but the page is not updated. I have to
select the visibility cell on each page and press "enter" to have the
page updated.

I have done some Google research and found out that this could be
caused by the
"display bug in Visio 2000 SR1". A workaround that only works once is
to activate each page in the VBA script before updating the
properties. But this is not a desired situation. Since I have only
found posts from 2002 regarding this issue, I am curious if other
workarounds are available for this issue.

I have the following VBA code to perform the visibility settings:

Private Sub SetLayerVisibility(pgobj As Visio.Page, layername As
String, visibility As Boolean)
Dim ilay As Integer
Dim layerobj As Visio.Layer


' Is the argument passed a Page?
If (Not (pgobj.ObjectType = visObjTypePage)) Then
' Passed obj is not a Page!
Debug.Print " SetLayerVisibility(): Passed argument is not
page object!"
Exit Sub
End If

If (pgobj.Layers.Count > 0) Then
'Iterate trough all layers to find the referenced layer
For ilay = 1 To pgobj.Layers.Count
Set layerobj = pgobj.Layers(ilay)
If (StrComp(layerobj.Name, layername) = 0) Then
Debug.Print " FOUND matching layer on page ";
pgobj.Name; " layer: "; layerobj.Name

Visio.ActiveWindow.Page = pgobj.Name 'Activate the
page; workaround for the display update bug in V2K SR1
layerobj.CellsC(visLayerVisible) = visibility
layerobj.CellsC(visLayerPrint) = visibility

End If
Next ilay
Else
Debug.Print " SetLayerVisibility(): No layers on page";
pgobj.Name

End If
End Sub


Private Sub FirewallCheckbox_Click()
Dim ipag As Integer
Dim pagobj As Visio.Page
Dim curpg As Visio.Page

'save the current activepage
Set curpg = ActiveWindow.Page

For ipag = 1 To ThisDocument.Pages.Count
Set pagobj = ThisDocument.Pages(ipag)

If (FirewallCheckbox.Value) Then
' Make Firewall layer visible
Call SetLayerVisibility(pagobj, "Firewall", True)
Else
' Make Firewall layer invisible
Call SetLayerVisibility(pagobj, "Firewall", False)
End If
Next ipag

'Restore the current active page
ActiveWindow.Page = curpg.Name

End Sub


I hope anyone can help me with this issue!

Regards,

Marco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top