Hi,

can anybody please tell me which object holds the information from the
"Table of Contents Options" dialogue? Specifically I'm after the bindings
between styles and TOC levels.

Many thanks in advance,

Rad

Re: "Table of Contents Options" by Charles

Charles
Mon Mar 13 14:48:53 CST 2006

These are field switches. The Table of Contents is a field.
http://sbarnhill.mvps.org/WordFAQs/TOCTips.htm
http://word.mvps.org/FAQs/Formatting/TOCSwitches.htm
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ 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.


<no.email@hotmail.com> wrote in message
news:%23tftI3pRGHA.4976@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> can anybody please tell me which object holds the information from the
> "Table of Contents Options" dialogue? Specifically I'm after the bindings
> between styles and TOC levels.
>
> Many thanks in advance,
>
> Rad
>



Re: "Table of Contents Options" by Stefan

Stefan
Tue Mar 14 05:45:49 CST 2006

The HeadingStyles object provides a way to add and delete custom
styles as table of contents entries (corresponding to the list after
the \t switch in the TOC field). To control which built-in heading
styles (or custom styles with an outline level defined in their
Paragraph formats) are used, you need the UseHeadingStyles property
and UpperHeadingLevel and LowerHeadingLevel properties. Read Word VBA
help for more.

The following is a very basic example which adds some custom styles to
be used in the TOC. (Note that the macro does not run if there isn't
already a TOC in the document. Also note that I haven't included a
test to see if the style names actually exist in the document.)

Sub main()
Dim tt As TablesOfContents
Dim h As HeadingStyle

Set tt = ActiveDocument.TablesOfContents

With tt
If .Count > 0 Then
While .Item(1).HeadingStyles.Count > 0
.Item(1).HeadingStyles(1).Delete
Wend
.Item(1).HeadingStyles.Add "test style 1", 1
.Item(1).HeadingStyles.Add "test style 2", 2
.Item(1).HeadingStyles.Add "test style 3", 3
.Item(1).HeadingStyles.Add "test style 4", 1
tt(1).Update
End If
End With


End Sub

Note that it might be easier to work directly with the TOC
field (accessible via a Fields collection).

--
Stefan Blom
Microsoft Word MVP


<no.email@hotmail.com> wrote in message
news:%23tftI3pRGHA.4976@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> can anybody please tell me which object holds the information from
the
> "Table of Contents Options" dialogue? Specifically I'm after the
bindings
> between styles and TOC levels.
>
> Many thanks in advance,
>
> Rad
>
>