Refresh Fields in Microsoft Word
Bookmark :
The concept of having page numbers and other fields in Word to dynamically display information works and sounds great. The only drawback is getting the information to stay up to date. Yes, there is the F9 feature that refreshes all the selected fields. Having to remember to select all the text and then press F9 is not bad. But the headers and footers are not selected so they do not get updated. Each different header needs to be updated individually. This macro will update all the fields in each section of the active document.
The concept of having page numbers and other fields in Word to dynamically display information works and sounds great. The only drawback is getting the information to stay up to date. Yes, there is the F9 feature that refreshes all the selected fields. Having to remember to select all the text and then press F9 is not bad. But the headers and footers are not selected so they do not get updated. Each different header needs to be updated individually. This macro will update all the fields in each section of the active document.
Create Macro
- Select Tools - Macro - Macros from the menu bar
- Enter RefreshAllFields for the 'Macro Name'
- Select 'Normal.doc' for 'Macros in'
- Select 'Create' option
- Copy the following text between Sub and End Sub
- Paste into Visual Basic Editor

Sub RefreshAllFields()
'
' RefreshAllFields Macro
'
'
'
' RefreshAllFields Macro
'
'
For i = 1 To ActiveDocument.Sections.Count
End SubIf Not ActiveDocument.Sections(i).Headers Is Nothing Then
Next iFor h = 1 To ActiveDocument.Sections(i).Headers.Count
End If
x = ActiveDocument.Range.Fields.Update()
If Not ActiveDocument.Sections(i).Footers Is Nothing Then
End Ifx = ActiveDocument.Sections(i).Headers(h).Range.Fields.Update()
Next hEnd If
x = ActiveDocument.Range.Fields.Update()
If Not ActiveDocument.Sections(i).Footers Is Nothing Then
For f = 1 To ActiveDocument.Sections(i).Footers.Count
x = ActiveDocument.Sections(i).Footers(f).Range.Fields.Update()
Next fx = ActiveDocument.Sections(i).Footers(f).Range.Fields.Update()
Run Macro
- Select Tools - Macro - Macros from the menu bar
- Select RefreshAllFields for List of macros
- Sit back and watch
I use this macro so often that I added it to my personal toolbar that is always displayed in every document.







Comments
Posted by Brian At 03:59:14 PM On 12/12/2007 | - Website - |
I have tables in my document that give an overview of each chapter. They contain fields linked to bookmarks, which display the page number in the table. These page numbers don't update as I edit the document, so I have to go to each "overview" table and manually right-click and select "update field."
This macro doesn't update those fields.
Posted by Tuck At 02:33:34 AM On 04/23/2008 | - Website - |
the page numbers won't update as you edit the document. They will update when you run the macro. It's automates the right-clicking and selecint "update field" that you are doing.
I've tried other similar scripts but somehow they all mess up some references. This seems to work the best so far.
Posted by JT At 01:20:13 PM On 05/11/2008 | - Website - |
Posted by akbr At 03:30:25 PM On 05/17/2008 | - Website - |
Alex
Posted by Alessandro Vernet At 02:42:15 PM On 05/21/2008 | - Website - |
Posted by Chad Schelfhout At 06:20:03 AM On 05/27/2008 | - Website - |
Posted by Meenal At 09:34:48 AM On 06/11/2008 | - Website - |
Any way to filter out images when iterating through?
Posted by Ryan At 08:48:43 AM On 07/15/2008 | - Website - |