How do I modify a table of contents with a VBA macro?

C

CarlS

I have a document that is not automated at all. It is a "Use Case" template
that we are supposed to cut and paste then fill in for each use case. I have
found that I can create a TOC at the beginning of the document and put in
hyperlinks, remove page numbers, etc. (The TOC is based on the Heading1,
Heading2 styles.)

What I would like to do is loop through each use case (maybe go to each
headng2 style?) and then drop down to the next cell, grab the use case
reference number, and than add that to the TOC.

Is this possible?
 
M

macropod

Hi Carl,

Unless the "Use Case" is added to the existing heading, or you use another heading level for it (which means it'll have its own line
in the TOC), it's not possible to add the "Use Case" to the Word TOC field.

The only way around that, that I can see, would be to use a macro to create a TOC, unlink it (so that is becomes a plain text
representation of the TOC), then go through each of the TOC headings and retrieve the corresponding "Use Case" details to append to
the unlinked TOC entry. To update the TOC when new "Use Cases" are added/inserted, you'd probably need to delete the existing TOC
and create a new one from scratch.
 

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