Automating TOC - Custom Styles

  • Thread starter Archie via OfficeKB.com
  • Start date
A

Archie via OfficeKB.com

Hi All

We have defined suites of numbering styles and have macros to insert a TOC
based on the suite in use. These are (mostly) custom styles rather than
Word's Heading styles. The user is presented with a custom dialog box and
ticks the items they want included - e.g. Level 1, Level 2, Schedule heading,
Appendix etc. The list of required styles & their TOC level is passed as a
string.

With ActiveDocument
.TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
LowerHeadingLevel:=3, UseFields:=True, IncludePageNumbers:=True,
AddedStyles:=strTocString, _
UseHyperlinks:=True, HidePageNumbersInWeb:=True
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With

An example of what might be contained in strTOCString is:

"S-A-Heading,4,S-A-Heading,3,Appendix,3,A-Level1,1,"

All works a treat in Word 2000.

However, in 2003 we now find that the TOC does not limit itself to the styles
the macro tells it to use (as defined in the above string) but inserts
entries based on the information shown when you choose 'Index & Tables >
Table of Contents > Options' i.e. the available styles. It looks as though
we now need to wipe out these settings and apply only the ones being sent by
the macro. Although there is a 'Reset' button on the above mentioned screen,
there does not seem to be a way of accessing that function programatically.
Moreover, it leaves the Heading styles 1-3 ticked. We don't necessarily want
those in the TOC.

Does anyone have an idea of how I can achieve this, please? Or should I be
doing this completely differently (but please not only using Word's Heading
styles - too limiting).

Thanks in advance for any help.

Archie
 
D

debbieprobert via OfficeKB.com

Cracked it! Change UseHeadingStyles to be False rather than True & works
just fine.

Thanks to anyone who would have answered.

Archie
 

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

Similar Threads

Table of Contents Styles font issue 5
Table of Contents Nightmare 1
Apply a paragraph style to a Table of Contents 1
Table of Content 1
TOC problem 0
TOC Help 0
TOC Problem 0
double spacing content of TOC 2

Top