DonnaM » Blog Archive » Visio and IA Tip – hide and show annotations

Visio and IA Tip – hide and show annotations

Here’s my latest useful visio trick – a macro that hides and shows annotations on all sheets at once (it hides them for view and print). Very useful when you want to print everything with or without annotations. Label your annotation layer “annotation” or change the annotation to reflect what you usually call that layer.

Let me know if this is useful or if there is a better way of doing it ;)

Public Sub HideAnnotationLayers()
Dim layer As Visio.layer
Dim PageToIndex As Visio.Page
Dim curPage As Visio.Page
Dim layerObjVisCell As Cell
Dim layerObjPrintCell As Cell
Set curPage = ActivePage
For Each PageToIndex In ActiveDocument.Pages
ActiveWindow.Page = ActiveDocument.Pages(PageToIndex.Index).Name
For Each layer In Visio.ActivePage.Layers
If (layer.Name = "Annotation") Then
Set layerObjVisCell = layer.CellsC(visLayerVisible)
Set layerObjPrintCell = layer.CellsC(visLayerPrint)
layerObjVisCell.Formula = 0
layerObjPrintCell.Formula = 0
End If
Next
Next
ActiveWindow.Page = curPage
End Sub
Public Sub ShowAnnotationLayers()
Dim layer As Visio.layer
Dim PageToIndex As Visio.Page
Dim curPage As Visio.Page
Dim layerObjVisCell As Cell
Dim layerObjPrintCell As Cell
Set curPage = ActivePage
For Each PageToIndex In ActiveDocument.Pages
ActiveWindow.Page = ActiveDocument.Pages(PageToIndex.Index).Name
For Each layer In Visio.ActivePage.Layers
If (layer.Name = "Annotation") Then
Set layerObjVisCell = layer.CellsC(visLayerVisible)
Set layerObjPrintCell = layer.CellsC(visLayerPrint)
layerObjVisCell.Formula = 1
layerObjPrintCell.Formula = 1
End If
Next
Next
ActiveWindow.Page = curPage
End Sub

9 Responses to “Visio and IA Tip – hide and show annotations”

  1. Rebecca Says:

    Hi Donna

    I have not used Visio yet, but am wondering if it would be useful for a project I am working on at the moment.

    I’m looking for an app you could use for a sitemap (tree style) that would keep an ID number, URL, and title for each page, for say 500 – 1200 pages. And with the ability to collapse / open nodes.

    Is this something you would expect to be able to do with Visio?

    Cheers :)

  2. Donna Maurer Says:

    I’d do that in Excel – use the group feature to expand and collapse.

  3. Xander Says:

    Great macro! I’ve wanted to figure out how to do this for a while. Thanks!

  4. Lori Caruso Says:

    I agree that Visio needs this functionality built in! Of COURSE, users want to hide them on every page, or show them on every page most often!!! LOL

    However, I’ve found a work-around that I’m quite happy with. It involves creating a PDF.
    Adobe Acrobat writer 8.0 allows you to maintain layers. Then, when you view the document in Acrobat reader 8.0, you can display a layers tab, much like the bookmarks tab. You can hide and show each layer throughout the document. It’s very cool for using wireframes in review sessions with the client, and then hiding the notes layers for user assessments. It’s also helpful for creating a layer to include drop-down components in the Visio, which you can turn on to show all of the drop-downs expanded at once.

  5. Yaniv Nord Says:

    Donna,

    First of all thanks for this Macro. It’s exactly what I was looking for. To a tee.

    There is one very minor issue that folks should be aware of when trying to copy and paste the above item into visio: The quotation marks wrapping the string “annonation” are of the curly variety (sometimes called smartquotes), rather than straight. The macro will not run as intended unless you change the quotation marks to straight quotes in your VB editor.

    Thank you.
    Yaniv Nord
    Brooklyn, New York

  6. Donna Spencer Says:

    Thanks Yaniv. I think I’ve fixed that.

  7. Bas Schipper Says:

    Thanks for sharing this as it is exactly what I was looking for. Works great in Visio 2007 as well.

  8. Barb Says:

    Donna – First, i’m wanting to use the TOC macro for visio documents that have multiple tabs…so a line item and/or link for each tab. Will this do that?

    And I’m not a programmer and have no idea how to get this macro into visio. is there some way that I just cut and paste it?

    Thanks so much!

  9. maadonna Says:

    Barb – here’s one for creating a TOC: http://stephenturbek.com/2007/04/automatically-create-table-of-contents.html

Leave a Reply