Refresh Fields in Microsoft Word

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

  1. Select Tools – Macro – Macros from the menu bar
  2. Enter RefreshAllFields for the ‘Macro Name’
  3. Select ‘Normal.doc’ for ‘Macros in’
  4. Select ‘Create’ option
  5. Copy the following text between Sub and End Sub
  6. Paste into Visual Basic Editor
Sub RefreshAllFields()
 '
 ' RefreshAllFields Macro
 '
 '
 For i = 1 To ActiveDocument.Sections.Count
 	If Not ActiveDocument.Sections(i).Headers Is Nothing Then
 		For h = 1 To ActiveDocument.Sections(i).Headers.Count
 			x = ActiveDocument.Sections(i).Headers(h).Range.Fields.Update()
 			 Next h
 		End 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 f
 		End If
 	Next i
 End Sub

Run Macro

  1. Select Tools – Macro – Macros from the menu bar
  2. Select RefreshAllFields for List of macros
  3. 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.

10 thoughts on “Refresh Fields in Microsoft Word

  1. I suppose I misunderstand the purpose of this macro.

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

  2. Tuck,

    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.

  3. This works for fields… but in a graphic rich document with lots of pasted screenshots, it will update every picture to be ONLY ONE picture, resized for each occurrence. I’ve tried a number of methods myself, but all such macros seem to do this…

    Any way to filter out images when iterating through?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">