Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I generate a table of contents(TOC) for a visio document?

3 views
Skip to first unread message

Geoff Liggins

unread,
Apr 11, 2002, 7:33:54 AM4/11/02
to
I am generating a relatively large flowchart, presently it has 250
working pages covering almost 500 printed pages. This process map is
still growing. I would like to generate a table of contents of the page
names that I can insert at the beginning of the Visio document. How do I
generate this list?

I am using Visio 2002 Pro.

Thanks in advance.

--
From the east coast

Geoff

******************************************************************
Geoffrey Liggins
Senior Research Engineer
C-CORE, Bartlett Building
Memorial University of Newfoundland
St. John's, NF, A1B 3X5, CANADA
office: (709) 737-7579 lab: (709) 737-8470 fax: (709) 737-4706
web site: http://www.c-core.ca
e-mail: Geoff....@c-core.ca
******************************************************************


Jacques Laurin

unread,
Apr 13, 2002, 10:23:50 AM4/13/02
to
Hi Geoff,
You could use a VBA program (macro) to do this.
Here's a short example that counts the number of shapes on a page. In your
case you will have to modify it get the name or information you want from
the shape object (see Help/Developer Reference for this) and save it to a
file.

Sub CountShapesOnPage()
Dim iShapeCount

'Call the shape counting function
iShapeCount = ShapesCount(ActivePage)

'Display the result in a message box
MsgBox "The shape count = " & iShapeCount
End Sub

Function ShapesCount(root As Object) As Integer
'Return value
Dim iCount As Integer
'Shapes collection
Dim shpsObj As Visio.Shapes
'Shape object
Dim shpObj As Visio.Shape
iCount = 0
'Assumes root.Shapes is a group or a page
Set shpsObj = root.Shapes
For Each shpObj In shpsObj
'If the shape is a group, don't count
'it, but do recursively count
'the shapes in the group
If shpObj.Type = visTypeGroup Then
iCount = iCount + ShapesCount(shpObj)
Else
iCount = iCount + 1
End If
Next
ShapesCount = iCount
End Function

Hope that helps,
jacques

"Geoff Liggins" <Geoff....@c-core.ca> wrote in message
news:3CB574A2...@c-core.ca...

Zack Moore [MS]

unread,
Apr 18, 2002, 6:35:09 PM4/18/02
to
Hi Geoff,

Jacque is right, VBA is that way. Here is another example of a VBA macro
that could work for you...

Sub CreateTableOfContents()

' creates a shape for each page in the drawing on the first page of the
drawing
' then adds a hyperlink to each shape so you can click and go to that
page


' define a toc shape
Dim TOCEntry As Visio.Shape
Dim PageToIndex As Visio.Page

' loop through all the pages you have
For Each PageToIndex In Application.ActiveDocument.Pages

' where to put the entry on the page?
Dim X As Integer

' you may want to refine this and use a top down algorithm with
something smaller than 1 inch increments.
X = PageToIndex.Index

' draw a rectangle for each page to hold the text
Set TOCEntry = ActiveDocument.Pages(1).DrawRectangle(1, X, 4, X + 1)

' write the page name in the rectangle
TOCEntry.Text = PageToIndex.Name

' add a hyperlink to point to the page to you can just go there with
a click
Dim hlink As Visio.Hyperlink

' need to create a handle to add the hyperlink
Set hlink = TOCEntry.AddHyperlink

' add a description
hlink.Description = PageToIndex.Name

' add the page name as an address
hlink.SubAddress = PageToIndex.Name


Next

End Sub

Cheers,


--
Zack Moore [MS]
This posting is provided "AS IS" with no warranties, and confers no rights.

"Jacques Laurin" <jlau...@earthlink.net> wrote in message
news:WbXt8.4521$3z3.4...@newsread1.prod.itd.earthlink.net...

0 new messages