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 / November 2005

Tip: Looking for answers? Try searching our database.

Update an entire document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark64 - 11 Nov 2005 17:07 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.  
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

Rate this thread:






 
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.