Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Automating TOC - Custom Styles

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Archie - 31 May 2006 17:27 GMT
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
debbieprobert - 31 May 2006 18:06 GMT
Cracked it!  Change UseHeadingStyles to be False rather than True & works
just fine.

Thanks to anyone who would have answered.

Archie

>Hi All
>
[quoted text clipped - 38 lines]
>
>Archie
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.