Auto-update of fields?

M

mlse

Hi, How can I make all the fields in my document automatically update
(e.g. like the page count field does by default) instead of having to
manually click on each field in turn and update it?

Thanks.
 
M

macropod

Hi mlse,

Most, if not all, of your fields will update if you do a Print Preview. Also make sure you've checked the:
.. 'update automatics links at open' option under Tools|Options|General
.. 'update fields' and 'update links' options under Tools|Options|Print.

If that's not enough for you, you can try the following macro:
Sub RefreshFields()
Dim TOC As TableOfContents ' Table of Contents Object
Dim TOA As TableOfAuthorities ' Table of Authorities Object
Dim TOF As TableOfFigures ' Table of Figures Object
Dim pRange As Range ' Word Range Object
Call MacroEntry
With ActiveDocument
' Loop through Story Ranges and update.
' Note that this may trigger interactive fields (eg ASK and FILLIN).
For Each pRange In .StoryRanges
Do
pRange.Fields.Update
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
' The following routines are necessary because the foregoing updates only page numbers
' in TOCs, TOAs and TOFs - field updating doesn't update TOC, TOA or TOF contents.
' Loop through Tables Of Contents and update
For Each TOC In .TablesOfContents
TOC.Update
Next
' Loop through Tables Of Authorities and update
For Each TOA In .TablesOfAuthorities
TOA.Update
Next
' Loop through Tables Of Figures and update
For Each TOF In .TablesOfFigures
TOF.Update
Next
End With
Call AcceptTrackedFields
Call MacroExit
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top