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 / September 2006

Tip: Looking for answers? Try searching our database.

Finding and Updating a Table of Contents in VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BBM - 21 Sep 2006 18:29 GMT
How does one
1)  Reference the Table of Contents of a Word Document through VBA

and

2)  Force it to update itself (perform F9 function).  It needs to do this
after the document has loaded, but before it is displayed to the user.

Thanks.

BBM
Jay Freedman - 21 Sep 2006 20:11 GMT
Bearing in mind that any document may have zero, one, two, or more tables of
contents, the following code will handle any of those situations:

   Dim TOC As TableOfContents

   For Each TOC In ActiveDocument.TablesOfContents
       TOC.Update
   Next

If your macro assigns the document in question to a variable of type
Document, then replace "ActiveDocument" with the name of that variable.

If your document also contains tables of authorities and/or tables of
figures created with fields of those types, then you'll need separate loops
to handle the members of the TablesOfAuthorities and TablesOfFigures
collections.

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

> How does one
> 1)  Reference the Table of Contents of a Word Document through VBA
[quoted text clipped - 8 lines]
>
> BBM
 
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.