View Single Post
  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Update Table of Contents

Just to stay honest... There's a buglet in that code that prevents it from
updating any Table of Figures. To fix it, add the line

Dim tof As TableOfFigures

after the Dim toc line, and change the last loop to this:

For Each tof In ActiveDocument.TablesOfFigures
tof.Update
Next

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

DeanH wrote:
Jay, fantastic. Many thanks for your very useful help.
All the best.
DeanH

"Jay Freedman" wrote:

This should update all the fields (including those in headers,
footers, footnotes, etc.) and then all the tables. If you have any
tables of authorities (for legal briefs and such), you'd need
another For Each loop for those.

Sub UpdateTableOfContents()
Dim toc As TableOfContents
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
Do
oStory.Fields.Update
Set oStory = oStory.NextStoryRange
Loop Until oStory Is Nothing
Next

For Each toc In ActiveDocument.TablesOfContents
toc.Update
Next

For Each toc In ActiveDocument.TablesOfFigures
toc.Update
Next
End Sub

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

DeanH wrote:
Jay, many thanks for your help.

To add:
This macro obviously only updates the tables, how about the
cross-references? My usual process is Ctrl-A, F9, then update entire
TOC x3.
This updates all cross-references, Figure & Table numbering, TOC and
List of Figures & Tables.

Again many thanks.
Have a good day.
DeanH

"Jay Freedman" wrote:

You can't really change the default, but you can install this macro
and assign a toolbar button and/or keyboard shortcut to it.

Sub UpdateTableOfContents()
Dim toc As TableOfContents

For Each toc In ActiveDocument.TablesOfContents
toc.Update
Next
End Sub

See http://www.gmayor.com/installing_macro.htm,
http://www.word.mvps.org/FAQs/Custom...roToHotkey.htm
and
http://www.word.mvps.org/FAQs/Custom...oToToolbar.htm
if needed.

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

On Fri, 3 Nov 2006 04:44:02 -0800, DeanH
wrote:

Word 2000 SP3

Is it possible to change the default setting of the Update Table
of Contents options from "Update page numbers only" to "Update
entire table" instead?

Many thanks in advance of your assistance.
DeanH