I have the following macro that I was given from another question here, which
I use to update an entire document, fields, headers, footers, everything.
However I have noticed that it is not updating my Table of Contents and Table
of Figures. Do I need to add something more to this.
Dim pRange As Word.Range
For Each pRange In ActiveDocument.StoryRanges
Do Until pRange Is Nothing
pRange.Fields.Update
Set pRange = pRange.NextStoryRange
Loop
Next
Tony Jollans - 11 Nov 2005 17:30 GMT
Yes, Fields.Update does not update TOC fields. try adding something like
this
Dim TOC As TableOfContents
For Each TOC In ActiveDocument.TablesOfContents
TOC.Update
Next
For a more complete solution you might like to try:
Dim TOC As TableOfContents
Dim TOF As TableOfFigures
Dim TOA As TableOfAuthorities
For Each TOC In ActiveDocument.TablesOfContents
TOC.Update
Next
For Each TOF In ActiveDocument.TablesOfFigures
TOF.Update
Next
For Each TOA In ActiveDocument.TablesOfAuthorities
TOA.Update
Next
--
Enjoy,
Tony
> I have the following macro that I was given from another question here, which
> I use to update an entire document, fields, headers, footers, everything.
[quoted text clipped - 8 lines]
> Loop
> Next
Mark64 - 11 Nov 2005 18:18 GMT
Awesome! Thanks Tony!
> Yes, Fields.Update does not update TOC fields. try adding something like
> this
[quoted text clipped - 38 lines]
> > Loop
> > Next
Jay Freedman - 11 Nov 2005 18:09 GMT
>I have the following macro that I was given from another question here, which
>I use to update an entire document, fields, headers, footers, everything.
[quoted text clipped - 8 lines]
> Loop
>Next
Yes, add one of these loops after the Next, depending on whether you
want to update the entries or just the page numbers of the existing
entries:
Dim oTOC As TableOfContents
For Each oTOC In ActiveDocument.TablesOfContents
oTOC.Update
Next oTOC
Dim oTOC As TableOfContents
For Each oTOC In ActiveDocument.TablesOfContents
oTOC.UpdatePageNumbers
Next oTOC
and a similar one for the Table of Figures.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org