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

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

Post by Geoff Liggin » Fri, 12 Apr 2002 20:33:54



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

******************************************************************

 
 
 

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

Post by Jacques Lauri » Sun, 14 Apr 2002 23:23:50


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


> 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

> ******************************************************************


 
 
 

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

Post by Zack Moore [MS » Sat, 20 Apr 2002 07:35:09


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.


> 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



> > 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

> > ******************************************************************

 
 
 

1. Generating table of contents for PDF (for PalmOS)

I have a PDF that I want to store on my PDA.  The PDF has an index with clickable links to jump to
chapters.  I'm trying to find some way to turn that set of links to something that will show up as a
jumpable table on contents on Acrobat for PalmOS.  Is there a way to do this?  The PDF in question
is found here http://www.herper.com/ebooks/titles/Water.html

2. Netmeeting together with AOL 6.0 and Win 95

3. Do MS-Word generated Table of Contents translate into PDF?

4. MVME761 module interface with VxWorks question...

5. Generating a PDF document from a text file in DOS

6. Showcase & PostScript->screen

7. Generating non-table text in ODS RTF (MS Word) document

8. Problems compiling pgp262 under gcc 2.7.2.2 on solaris x86 v2.5?

9. Generating parse-table for table-driven EBNF parser.

10. Creating a Visio document from an ASP document

11. inserting multi page Visio document into a Word document

12. Open old VISIO-Document in Visio 4.0