Autotext TOC

T

Tel

Hi everyone,

I've inherited a number of templates which contain a Table of Contents built
within an autotext entry.
This works OK, the user just types the autotext, hits F3 and the TOC
magically appears.
However, has anyone created a TOC with code instead of autotext?

Any help gratefully received.
 
D

Dave Lett

Hi,

Are you looking for something as simple as the following:

ActiveDocument.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldTOC, _
Text:="", _
Preserveformatting:=True

If you want to insert any field switches, then add that to the Text parameter.

HTH,
Dave
 
C

Charles Kenyon

Just curious. What's wrong with Insert => Indexes & Tables => Table of
Contents?
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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