Home → Resources → Articles

Visio Macro To List Document Tabs

(Microsoft Visio,Microsoft VBA) by Jason Skowronek on 06/17/2010

I wrote up quickly to throw a sequential list of all the tabs (pages) of a Microsoft Visio document into a Shape (e.g. table of contents).

  1. Create your overview page
  2. Drop a shape onto the canvas
  3. Open the shape sheet and assign the sheet a name (mine is called "Tabs")
  4. Open the VBA editor (ALT + F11)
  5. Paste the code from below into your document's code window
  6. Make sure the name of your shape matches the Shape reference in the code
  7. Right-click the shape and assign a macro behavior to the new macro/method
  8. Double-click the shape
  9. You're welcome
Public Sub FillOverViewPage()
    Dim vsoChars As Visio.Characters
    Dim vsoPages As Visio.Pages
    Dim i As Integer
    
    Set vsoPages = Me.Pages
    Set vsoChars = Me.Pages(1).Shapes("Tabs").Characters
    
    ' clear whats in there now
    vsoChars.Text = ""
    
    ' loop pages and add page name to the chars
    For i = 1 To vsoPages.Count
        If vsoPages(i).Background = False Then
            vsoChars.Text = vsoChars.Text & i & " - " & vsoPages(i).Name & vbCrLf
        End If
    Next i
End Sub

Comments (1)

Tomtom

11/2/2011 4:26:46 AM
Hello, Thanks you so much for your macro, it is very helpfull for me. I just want to add that in visio 2010 you can name and add properties to your shabe by the developer ribbon in the section shape creation with the buttons "Shape Name" and "Comportment". I add this for the newbies like me who looks in shape sheet and in the right-click menu. I also have a question, do you think it is possible to have the tab number next to the tab name in the shape ? My objective is to make an index of my document, can you help me ? Thank you
Leave a comment
Name *
Email *
Homepage
Comment

SkoNet provides comprehensive digital consulting services such as: web development, applications development, database design and architecture, business process management, customer relationship management, and many others that help businesses of every size, industry, and geography meet the complex challenge of managing and sharing information on the web. Our skills and expertise in online systems allow us to help customers build applications ranging from simple, single-page web sites to robust enterprise systems.

Online Backup, Ektron Consulting, Ektron Programmer, Ektron Developer, Ektron Partner Utah, Ektron Partner, Ektron Architect, Ektron Hosting, Salesforce.com Consultant Utah, Salesforce.com Partner Utah, Salesforce.com Partner, Salesforce.com Programmer, Salesforce.com Architect, Salesforce.com APEX Programmer