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
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