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.

RE: Autotext TOC by anonymous

anonymous
Tue Jan 27 14:11:07 CST 2004

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

Re: Autotext TOC by Charles

Charles
Tue Jan 27 17:56:31 CST 2004

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.

"Tel" <dontwantany@spam.com> wrote in message
news:%23my5vDO5DHA.2416@TK2MSFTNGP10.phx.gbl...
> 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.
>
>