Updating all fields in word

Word for Microsoft 365 Word 2021 Word 2019 Word 2016 Word 2013 More…Less

Sometimes you need to manually trigger an update of the information in fields like those used in a table of contents, headers and footers, cross-references, bookmarks, and formulas in tables. You can update fields one by one, or you can update all the fields in your document at once.

In this article

  • Update a field

  • Update all fields in a document

Update a field

  1. In a document you have open, right-click a field, such as a table of contents, a page number, or a cross-reference, and click Update Field.

    The right-click menu for a bookmark reference

    Notes: 

    • If you’re updating a table of contents, in the Update Table of Contents dialog box, select whether you want to update page numbers only or the entire table. Updating page numbers only simply updates the page numbers for the existing sections. It doesn’t add new sections to your table of contents. To update your table of contents with new sections from your document, select Update entire table.

      Update Table of Contents dialog box

    • If you’re having trouble distinguishing which parts of your text are fields, you can set all fields to show up with grey background. To do this, click FILE > Options > Advanced, and under Show document content, from the Field shading drop-down menu, select Always.

      In the Advanced screen, set "Field shading" to "Always."

Top of Page

Update all fields in a document

  1. Press Ctrl + A.

  2. Press F9.

  3. If your document has tables with fields or formulas, you might need to select each table separately and press F9.

    Tip: To make sure that you don’t forget to update your table of contents before you print the document, set Word to update fields automatically before printing. Click FILE > Options > Display, and under Printing options, select the check box for Update fields before printing.

    In the Display screen, select "Update fields before printing."

    Note: Sometimes a field is not updated because the item the field refers to no longer exists. The link or bookmark might also be broken. For more information, see Troubleshoot bookmarks.

Top of Page

See Also

Insert fields

Field codes in Word

Create or update a cross-reference

Update a table of contents

Use a formula in a Word or Outlook table

Create a table of contents

Need more help?

Update Fields in Your Microsoft Word Documents Manually or Automatically

by Avantix Learning Team | Updated April 6, 2021

Applies to: Microsoft® Word® 2010, 2013, 2016, 2019 or 365 (Windows)

If you have inserted fields in your Microsoft Word document, you can choose to update them manually or have them update automatically. For fields you update manually, you can update just one field or update all the fields in your Word document at once. Some fields, such as page numbers, will automatically update when you preview your document. Many fields are set by default to update when you open a document but you can also set an option in Microsoft Word to update fields when you preview your file.

You can insert fields in several ways in Word. Some fields are created when you use Word’s built-in features (such as inserting a table of contents, a cross-reference, a bookmark or a page number). Other fields can be inserted using the Field dialog box or can be entered using keyboard shortcuts.

Recommended article: How to Insert Built-in and Custom Fields in Microsoft Word

Updating a single field

You can update a single field manually in two ways:

  1. Right-click the field and select Update Field. Depending on the type of field, another dialog box may appear where you can select other options (this occurs for example, with a tables of contents).
  2. Click the field and press F9.

Update field appears in the drop-down menu when you right-click a field:

Context menu that appears when you right-click on a field to update the field.

Updating all fields in the body of a Word document

To manually update all fields in the body of a Word document:

  1. Click in the body of the Word document.
  2. Press Ctrl + A.
  3. Press F9.

Updating fields in headers, footers or text boxes

Some fields in headers, footers or text boxes must be updated separately.

To update fields in headers, footers or text boxes:

  1. Click in the header, footer or text box.
  2. Pess Ctrl + A to select all.
  3. Press F9.

Page fields do not need to be updated manually.

Updating a table of contents field

If you update a table of contents, another dialog box appears. In the Update Table of Contents dialog box, select Update page numbers only if no content has changed. Select Update entire table to update page numbers and content.

Updating fields before printing or previewing

You can set an option in Microsoft Word to ensure that all fields are updated automatically before previewing (to preview, click the File tab in the Ribbon and then click Print):

  1. Click the File tab in the Ribbon and click Options at the bottom. A dialog box appears.
  2. Click Display in the categories on the left.
  3. Scroll down to the Printing options area in the panel on the right.
  4. Ensure the check box for Update fields before printing is checked.
  5. Click OK.

The Word Options dialog box where Update field before printing has been checked appears as follows:

Updating all fields in Word showing dialog box with update fields before printing checked.

Preventing field updating

You can prevent fields from updating by locking them.

To lock a field so that it is not updated, click the field, and then press Ctrl + F11. To unlock a field so that it can be updated, click the field, and then press Ctrl + Shift + F11.

Displaying fields with grey shading

You can change your options in Microsoft Word so that all fields are displayed with grey shading (the shading does not print). This can be helpful to determine where you have fields in your document.

To display fields with grey shading:

  1. Click the File tab in the Ribbon and click Options at the bottom. A dialog box appears.
  2. Click Advanced in the categories on the left.
  3. Scroll down to Show document content area in the panel on the right.
  4. Select Always from the drop-down menu for Field shading.
  5. Click OK.

The Word Options dialog box with Field shading set to Always appears as follows:

Microsoft Word dialog box with Field Shading turned on.

You may not want to display field shading permanently. The default setting is Field shading when selected.

Fields are a very powerful way of using variable content in Microsoft Word documents. However, if fields do not update, your document can display errors or inaccurate content.

Subscribe to get more articles like this one

Did you find this article helpful? If you would like to receive new articles, join our email list.

More resources

How to Insert a Watermark in Word (like DRAFT)

14+ Word Selection Shortcuts to Quickly Select Text

How to Find and Replace in Word (and use Wildcards)

How to Superscipt or Subscript in Word (with Shortcuts)

How to Keep Text Together in Microsoft Word (Words, Lines or Paragraphs)

Related courses

Microsoft Word: Intermediate / Advanced

Microsoft Word: Designing Dynamic Word Documents Using Fields

Microsoft Word: Long Documents Master Class

Microsoft PowerPoint: Intermediate / Advanced

VIEW MORE COURSES >

Our instructor-led courses are delivered in virtual classroom format or at our downtown Toronto location at 18 King Street East, Suite 1400, Toronto, Ontario, Canada (some in-person classroom courses may also be delivered at an alternate downtown Toronto location). Contact us at info@avantixlearning.ca if you’d like to arrange custom instructor-led virtual classroom or onsite training on a date that’s convenient for you.

Copyright 2023 Avantix® Learning

Microsoft, the Microsoft logo, Microsoft Office and related Microsoft applications and logos are registered trademarks of Microsoft Corporation in Canada, US and other countries. All other trademarks are the property of the registered owners.

Avantix Learning |18 King Street East, Suite 1400, Toronto, Ontario, Canada M5C 1C4 | Contact us at info@avantixlearning.ca

I want a way of updating all fields in a Word 2013 document. (If it works in other versions, all the better; I originally had this problem with Word 2007, and nothing seems to have changed since then.) This includes cross-references, page numbers, tables of contents, indexes, headers, etc. If it can be updated by pressing F9, I want it updated.

(In theory updating fields can cause other fields to need updating, e.g. a longer table of contents changes some page numbers in the main text. Taking care of the common cases is good enough for me. In fact, it’s ok if I have to run the macro two or three times before it stabilizes. I just want to have a single macro that finds everything.)

My attempt so far doesn’t update fields in text boxes inside figures. How do I update them, and what else have I missed?


EDIT: Combining the answer given with what I already had gives a macro that seems to update everything (with a known defect).

'' Update all the fields, indexes, etc. in the specified document.
Sub UpdateAllFieldsIn(doc As Document)
    '' Update tables. We do this first so that they contain all necessary
    '' entries and so extend to their final number of pages.
    Dim toc As TableOfContents
    For Each toc In doc.TablesOfContents
        toc.Update
    Next toc
    Dim tof As TableOfFigures
    For Each tof In doc.TablesOfFigures
        tof.Update
    Next tof
    '' Update fields everywhere. This includes updates of page numbers in
    '' tables (but would not add or remove entries). This also takes care of
    '' all index updates.
    Dim sr As range
    For Each sr In doc.StoryRanges
        sr.Fields.Update
        While Not (sr.NextStoryRange Is Nothing)
            Set sr = sr.NextStoryRange
            '' FIXME: for footnotes, endnotes and comments, I get a pop-up
            '' "Word cannot undo this action. Do you want to continue?"
            sr.Fields.Update
        Wend
    Next sr
End Sub
'' Update all the fields, indexes, etc. in the active document.
'' This is a parameterless subroutine so that it can be used interactively.
Sub UpdateAllFields()
    UpdateAllFieldsIn ActiveDocument
End Sub

How to update all field in Word (Windows and Mac OS)

Table of contents, page number, list of figures/tables/equations, figure/table/equation number and cross reference are some common example of fields. Sometimes you need to update all fields in Ms Word rather than updating each one by one. There are a couple of ways to do it. However, each method has its limitations and doesn’t update each type of field.

This blog describes the correct procedure that ensure every field are updated correctly.

Different ways to update all fields

Method 1: Print preview

Creating print preview updates all field if set correctly. Use print preview shortcut “Control + P” for Windows or “Command + P” for MacOS. Then press esc to move out of it.

Note: This method updates most of the fields including the ones in header and footer.

Before using this method, you need make sure that update field setting in print option is enabled.

Steps to enable “Update Field”

  1. Go to Word Options using Files > Options (Windows) or Word> Preferences (MacOS). You can also use MacOS shortcut Command + ,.
  2. Go to Display Tab > Printing Options Group (Windows) or Print (MacOS) and check box against “Update field before printing” or “Update field”

How to update all fields before printing in Word for Windows

Update all fields before printing in Word for Windows
Update all fields before printing in Word for MacOS
Update all fields before printing in Word for MacOS

Limitations of print preview method

Print preview method doesn’t update fields like table of contents and list of figures/tables/equations which need additional user input before updating.

Method 2: Select All and Update

  1. select all text using “Ctrl +A” and,
  2. press F9 (shortcut to update field)

This method overcomes limitations of the previous method and updates all the fields in selected text including table of contents and list of figures/tables/equations.

Limitations of select all and update method

The fields in header & footer doesn’t get update as their contents are not selected while selecting all text.

Order in which fields get update

Both the method updates fields in the order in which they appear. In other words, the field which appear earlier gets updated earlier. for e.g. if figure is cross referred before it appears (which is more likely) then the cross reference gets updated before the figure number to which it refers. In such case changed figure number doesn’t get reflected in cross reference after first try to update all field.

How to ensure all fields get updated?

How to update all field in Ms Word

To ensure all the fields gets updated to its correct value, first update all fields using “Print preview” method first and then again update all fields using “Select All & Update” method.

Above order ensures that all the fields (like Table of contents, list of figures/tables/equations, figure/table/equation number along with all cross references and fields in header & footer) gets updated properly.

Word supports many different types of fields. A field is a set of codes that instructs Word to automatically insert material into a document. Some of the commonly used fields are PAGE fields that show page numbers and TOC fields that display a table of contents.

In order for fields to show the correct result, they must be updated. Some types of fields are updated automatically by Word whereas other fields must be updated by the user.

In this article, you will find information about how each kind of Word field works in relation to updating. Find out which fields are updated automatically by Word and which fields you must update manually. For each field, you will also find field names and numbers that can be used in VBA if you need to create or edit fields via macros.

Most fields in the header and footer are updated automatically when you open a document.

However, FILENAME fields in the header or footer are not updated automatically when opening a document. According to information in the Microsoft article The FILENAME field does not automatically update when you open a document in Word, this special handling of FILENAME fields was introduced as a design change in Word 2002 to allow documents to open more quickly. It would indeed be an advantage to have FILENAME fields update automatically when opening a document — the speed would most likely not be a problem anymore. You need to update the fields. See How to update fields.

Fields in headers and footers are updated when you switch to Print Preview

When you switch to Print Preview, all fields in the header and footer are updated. This will also trigger FILLIN and ASK fields in the header or footer.

Fields in footnotes, endnotes, text boxes and shapes

As is true for headers and footers, footnotes, endnotes, text boxes and shapes you create using the tools in Insert tab > Illustrations group > Shapes reside in their own layers in a Word document, separated from the main body.

As explained above, fields in headers and footers are updated more automatically than other fields. This automatic control does not apply to fields in footnotes, endnotes, text boxes and shapes. This also means that you may need to manually take care of the field update in those areas of a document. See How to update fields below. 

Note that a text box in Word is actually a shape which means that it acts as other shapes in relation to updating fields.

The easiest way to update all fields in a document with fields spread across several layers is to use a macro. You will find my macro for updating fields here: Macro – Update All Fields in Word Document.

You can read more about the different layers in a Word document later in this article.

Fields in the main body of documents

The rules that apply to how different types of fields update — cold, warm and hot fields

In the table below, all Word fields are listed and organized based on the way they are updated in the main body of documents.

I have used the terms coldwarm, and hot in this relation. Those terms are used in VBA and they can give an indication of how the individual fields work in relation to updating. In the table below, you will find a short description of the characteristics of each of these kinds of fields. For each kind, you will also find a list of all Word fields of that kind.

In the Color code column in the table below, I have assigned a color to each field kind. Those colors are also used in the list of all Word fields sorted alphabetically. The purpose is to make it easier to overview the lists.

In VBA, the wdFieldKind enumeration can be used to return the kind of field. See column 3 in the table below — it shows the wdFieldKind constants and the related numbers. For example, you can return the kind of the first field in the selection using the following VBA code:

The rightmost column lists all fields of each kind.

Kind

Color code

VBA – wdFieldKind

Description – how fields are updated

Fields grouped by kind

Cold

3
wdFieldKindCold

A field that doesn’t have a result.

This also means that a cold field includes nothing to be updated.

PRIVATE
RD
TA
TC
XE

Warm

2
wdFieldKindWarm

A field that has a result and that can be updated.

The group of warm fields include both fields that are automatically updated when the source changes and fields that can be manually updated.

See also “Warm ++” below.

See How to update fields for more details about manually updating fields.

= (FORMULA)
ADDIN
ADDRESSBLOCK
ASK
AUTHOR
AUTOTEXT
AUTOTEXTLIST
BIBLIOGRAPHY
CITATION
COMMENTS
COMPARE
CONTROL
CREATEDATE
DATA
DATABASE
DDE
DDEAUTO
DOCPROPERTY
DOCVARIABLE
EDITTIME
EMBED
FILENAME
FILESIZE
FILLIN
FORMTEXT
GLOSSARY
GREETINGLINE
HYPERLINK
INCLUDE
INCLUDETEXT
INDEX
INFO
KEYWORDS
LASTSAVEDBY
LINK
MERGEFIELD
MERGEREC
MERGESEQ
NEXT
NEXTIF
NUMCHARS
NUMWORDS
QUOTE
REVNUM
SECTION
SET
SKIPIF
SUBJECT
TEMPLATE
TITLE
TOA
TOC
USERADDRESS
USERINITIALS
USERNAME

Warm ++

2
wdFieldKindWarm

The term “Warm ++” is invented here for descriptive purposes.

The description of Warm above applies but, in addition, these fields can be updated in one more way: Most of these fields are related to pagination and printing of documents.

These fields can be updated by switching to Print Preview because this triggers repagination of the document. This is the case no matter whether the option File > Options > Display > Printing options group > Update fields before printing is ON or OFF.

Printing a document or opening a document in Print Layout view will also cause these fields to update.

DATE
FTNREF
IF
NOTEREF
NUMPAGES
PAGE
PAGEREF
PRINTDATE
REF
SAVEDATE
SECTIONPAGES
SEQ
STYLEREF
TIME

Hot

1
wdFieldKindHot

A field that is automatically updated each time it is displayed or each time the page is reformatted.

These fields can also be updated manually. See How to update fields for more details about manually updating fields.

Note that you must save the document to retain the results of automatically updated fields.

ADVANCE
AUTONUM
AUTONUMLGL
AUTONUMOUT
BARCODE
BIDIOUTLINE
EQ
FORMCHECKBOX
FORMDROPDOWN
GOTOBUTTON
IMPORT
INCLUDEPICTURE
LISTNUM
MACROBUTTON
PRINT
SHAPE
SYMBOL

None

0
wdFieldKindNone

An invalid field such as an empty field. If you create fields manually, you can start with an empty field. Examples of invalid fields:
{ }
{ 123 }

See How to create fields manually.

(Empty field)

All Word fields sorted alphabetically — incl. VBA references

Below, you will find a list of all the different Word fields. For each field type, you will find the following information:

  • Field name — shows the field name as it appears when viewing field codes.
  • Kind — shows whether the field is Cold, Warm, Warm ++, Hot or None. See the color codes introduced above.
  • # and VBA wdFieldType Enumeration — show the number and the corresponding constant that can be used in VBA for the field in question.
  • Comment — shows special information about some fields.

Field name

Kind

#

VBA wdFieldType

Comment

Warm

82

wdFieldSubscriber

Subscriber field (I have not found any information about that field).

91

wdFieldHTMLActiveX

Not currently supported.

(Empty field
no name)

None

-1

wdFieldEmpty

Empty field. Acts as a placeholder for field content that has not yet been added.

= (FORMULA)

Warm

34

wdFieldExpression

 

ADDIN

Warm

81

wdFieldAddin

Not available through the Field dialog box. Used to store data that is hidden from the user interface.

ADDRESSBLOCK

Warm

93

wdFieldAddressBlock

ADVANCE

Hot

84

wdFieldAdvance

ASK

Warm

38

wdFieldAsk

AUTHOR

Warm

17

wdFieldAuthor

AUTONUM

Hot

54

wdFieldAutoNum

AUTONUMLGL

Hot

53

wdFieldAutoNumLegal

AUTONUMOUT

Hot

52

wdFieldAutoNumOutline

AUTOTEXT

Warm

79

wdFieldAutoText

AUTOTEXTLIST

Warm

89

wdFieldAutoTextList

BARCODE

Hot

63

wdFieldBarCode

BIBLIOGRAPHY

Warm

97

wdFieldBibliography

BIDIOUTLINE

Hot

92

wdFieldBidiOutline

 

CITATION

Warm

96

wdFieldCitation

COMMENTS

Warm

19

wdFieldComments

COMPARE

Warm

80

wdFieldCompare

CONTROL

Warm

87

wdFieldOCX

OCX field. Cannot be added through the Field dialog box but can be added via code by using the AddOLEControl method of the FormFields collection.

CREATEDATE

Warm

21

wdFieldCreateDate

DATA

Warm

40

wdFieldData

DATABASE

Warm

78

wdFieldDatabase

DATE

Warm ++

31

wdFieldDate

DDE

Warm

45

wdFieldDDE

No longer available through the Field dialog box but supported for documents created in earlier versions of Word.

DDEAUTO

Warm

46

wdFieldDDEAuto

No longer available through the Field dialog box but supported for documents created in earlier versions of Word.

DOCPROPERTY

Warm

85

wdFieldDocProperty

DOCVARIABLE

Warm

64

wdFieldDocVariable

EDITTIME

Warm

25

wdFieldEditTime

EMBED

Warm

58

wdFieldEmbed

 

EQ

Hot

49

wdFieldFormula

 

FILENAME

Warm

29

wdFieldFileName

FILESIZE

Warm

69

wdFieldFileSize

FILLIN

Warm

39

wdFieldFillIn

FORMCHECKBOX

Hot

71

wdFieldFormCheckBox

Inserted via Developer tab > Controls group > Legacy Tools > Check Box Form Field button or via code.

FORMDROPDOWN

Hot

83

wdFieldFormDropDown

Inserted via Developer tab > Controls group > Legacy Tools > Drop-Down Form Field button or via code.

FORMTEXT

Warm

70

wdFieldFormTextInput

Inserted via Developer tab > Controls group > Legacy Tools > Text Form Field button or via code.

FTNREF

Warm ++

5

wdFieldFootnoteRef

Not available through the Field dialog box. Inserted programmatically or interactively.

GLOSSARY

Warm

47

wdFieldGlossary

No longer supported in Word.

GOTOBUTTON

Hot

50

wdFieldGoToButton

GREETINGLINE

Warm

94

wdFieldGreetingLine

HYPERLINK

Warm

88

wdFieldHyperlink

IF

Warm ++

7

wdFieldIf

IMPORT

Hot

55

wdFieldImport

Cannot be added through the Field dialog box but can be added interactively or via code.

INCLUDE

Warm

36

wdFieldInclude

Cannot be added through the Field dialog box but can be added interactively or via code.

INCLUDEPICTURE

Hot

67

wdFieldIncludePicture

INCLUDETEXT

Warm

68

wdFieldIncludeText

INDEX

Warm

8

wdFieldIndex

INFO

Warm

14

wdFieldInfo

KEYWORDS

Warm

18

wdFieldKeyWord

LASTSAVEDBY

Warm

20

wdFieldLastSavedBy

LINK

Warm

56

wdFieldLink

LISTNUM

Hot

90

wdFieldListNum

MACROBUTTON

Hot

51

wdFieldMacroButton

MERGEFIELD

Warm

59

wdFieldMergeField

MERGEREC

Warm

44

wdFieldMergeRec

MERGESEQ

Warm

75

wdFieldMergeSeq

NEXT

Warm

41

wdFieldNext

NEXTIF

Warm

42

wdFieldNextIf

NOTEREF

Warm ++

72

wdFieldNoteRef

NUMCHARS

Warm

28

wdFieldNumChars

NUMPAGES

Warm ++

26

wdFieldNumPages

NUMWORDS

Warm

27

wdFieldNumWords

PAGE

Warm ++

33

wdFieldPage

PAGEREF

Warm ++

37

wdFieldPageRef

PRINT

Hot

48

wdFieldPrint

PRINTDATE

Warm ++

23

wdFieldPrintDate

PRIVATE

Cold

77

wdFieldPrivate

QUOTE

Warm

35

wdFieldQuote

RD

Cold

11

wdFieldRefDoc

REF

Warm ++

3

wdFieldRef

REVNUM

Warm

24

wdFieldRevisionNum

SAVEDATE

Warm ++

22

wdFieldSaveDate

SECTION

Warm

65

wdFieldSection

SECTIONPAGES

Warm ++

66

wdFieldSectionPages

SEQ

Warm ++

12

wdFieldSequence

SET

Warm

6

wdFieldSet

SHAPE

Hot

95

wdFieldShape

SKIPIF

Warm

43

wdFieldSkipIf

STYLEREF

Warm ++

10

wdFieldStyleRef

SUBJECT

Warm

16

wdFieldSubject

SYMBOL

Hot

57

wdFieldSymbol

TA

Cold

74

wdFieldTOAEntry

Table of Authorities Entry field.

TC

Cold

9

wdFieldTOCEntry

Table of Contents Entry field.

TEMPLATE

Warm

30

wdFieldTemplate

TIME

Warm ++

32

wdFieldTime

TITLE

Warm

15

wdFieldTitle

TOA

Warm

73

wdFieldTOA

Table of Authorities field.

TOC

Warm

13

wdFieldTOC

Table of Contents field.

USERADDRESS

Warm

62

wdFieldUserAddress

USERINITIALS

Warm

61

wdFieldUserInitials

USERNAME

Warm

60

wdFieldUserName

XE

Cold

4

wdFieldIndexEntry

Index Entry field.

How to create fields manually

A field added by pressing Ctrl+F9 in a Word document is an Empty field (wdFieldEmpty = -1, field kind None).

Instead of inserting fields via Insert tab > Quick Parts > Fields, you can create fields manually in Word:

  1. Press Ctrl+F9 to add an empty field.
  2. Type the relevant field code between the field brackets.

    See the Microsoft article List of field codes in Word for information about the individual types of Word fields and their syntax.

  3. Press F9 to update the new field.

If you know the syntax of the field you want to insert, the manual method is often the most efficient.

The kind of field will change from None / wdFieldKindNone to one of the other types once you add valid field code.

Field names are not case-sensitive

If you check the field codes of fields that are inserted in Word via the Fields dialog box (Insert tab > Quick Parts > Fields) or by using another command that results in a field being inserted (cross-reference, caption, date, etc.), you will see that Word will use UPPERCASE for the field name. Examples:

{ PAGE }
{ REF _Ref517270969 h }
{ TOC o «1-3» h z u }

Field names are not case-sensitive. For example, a PAGE field will work no matter whether the type is written as PAGE, Page, page, pAge or any other combination of uppercase and lowercase.

Why does Word not update all fields when I select all and press F9 to update fields?

A fast method to update fields in Word is to press Ctrl+A to select all and then press F9 to update fields. However, you may have experienced that this will not catch and update all fields. If the selection is in the main body of the document, Word only updates fields in that area of the document. It may not even update all fields there. If fields are found in text boxes or other shapes in the main body of the document, those fields will not be updated. Read on to find out why.

Content in a Word document is placed in different layers – called stories in VBA

Content in Word is placed in different layers, referred to as stories in VBA. Word can only «see» the content in one layer at a time. If your selection is in the main story, the content in e.g. headers and footers is not currently «visible» to Word. Also, shapes (text boxes, circles, rectangles, etc.) in the main body of the document are not in the text layer but in the drawing layer.

There are several different layers, or stories, in a Word document, actually a total of 17 different types as you will see below. There may not be content in every layer, though.

Principles for getting access to the different stories in VBA

Each story in a Word document may contain objects belonging to other stories. Therefore, you may need to access the objects like opening a Chinese box.

Example: In order to update fields in shapes in the headers of a Word document in VBA, you first need to access the correct type of header. There are, as you may know and as you can also see in the overview of story types below, not only one header story but three: even pages, first page and all other pages. Even pages headers are only visible in a Word document if Page Setup > Layout tab > Different odd and even is turned on in the section in question. Correspondingly, first page headers are only visible in sections that have Page Setup > Layout tab > Different first page turned on.

Shapes – drawing objects – that can include text can also include fields

All shapes that can include text can also include fields – and as fields elsewhere in a Word document, fields in shapes also need to be updated. Therefore, it is useful to understand how Word treats shapes like text boxes, circles, rectangles and other drawing objects with text.

If you right-click a shape that does not have any text, you should see the Add Text command in the context menu if the type of shape can include text.

Shapes can only be inserted in certain parts of a document

If you try to insert a text box or another shape in e.g. a footnote, Word will show the warning in Figure 2 below.

List of objects into which you can’t insert a drawing object

  • Text box
  • Callout
  • Comment
  • Footnote
  • Endnote

Message – you can't put drawing objects in all areas of a Word document.

Figure 2. Message – you can’t put drawing objects in all areas of a Word document.

Overview of layers in a Word document – story types in VBA

As explained above, the content in a Word document is spread across a number of layers, called stories in VBA.

The table below lists the names and numbers of the different story types in VBA. The rightmost column includes information about how the story is related to the content in the Word document.

All the story type are members of the WdStoryType collection.

WdStoryType

Constant name

WdStoryType

Enumeration

Where is the story in the document

wdMainTextStory

1

The main text in the document

wdEvenPagesHeaderStory

6

Text in even pages headers

wdFirstPageHeaderStory

10

Text in first page headers

wdPrimaryHeaderStory

7

Text in all other headers

wdEvenPagesFooterStory

8

Text in even pages footers

wdFirstPageFooterStory

11

Text in first page footers

wdPrimaryFooterStory

9

Text in all other footers

wdFootnotesStory

2

Text in footnotes

wdFootnoteSeparatorStory

12

Text in the layer with the footnote separator

wdFootnoteContinuationSeparatorStory

13

Text in the layer with footnote continuation separator

wdFootnoteContinuationNoticeStory

14

Text in the layer with footnote continuation notice

wdEndnotesStory

3

Text in endnotes

wdEndnoteSeparatorStory

15

Text in the layer with the endnote separator

wdEndnoteContinuationSeparatorStory

16

Text in the layer with endnote continuation separator

wdEndnoteContinuationNoticeStory

17

Text in the layer with endnote continuation notice

wdCommentsStory

4

Text in comments

wdTextFrameStory

5

Text in text boxes and other shapes

How to update fields

Hot fields are updated automatically by Word as described above.

Some warm fields are updated automatically when the source changes. Warm fields that are not updated automatically by Word can be updated manually. You can use different methods as described below.

METHOD 1 — Select the field and update it

  1. Select the field you want to update.
    If you want to update all fields in the current part of the document, press Ctrl+A to select all.
  2. Press F9 to update all fields in the selection.
    Alternatively, right-click and select Update Field from the context menu.

    If the selection includes one or more TOC fields, you will be asked once per TOC how you want the table of contents to be updated.

Note that this method only works in the area of the document where the selection is. If there are fields in e.g. footnotes or endnotes, you need to select those areas individually and update fields.

TIP: If you experience that one or more cross-reference fields do not update as expected, see the article Cross-reference Problems — Troubleshooting.

METHOD 2 — Switch to Print Preview

As mentioned in the description of Warm ++ fields, they can be updated by switching to Print Preview. This method is not sufficient if other kinds of fields need to be updated.

  1. To quickly switch to Print Preview, press Alt+Ctrl+I.
  2. To quickly return to the previous view type, press Esc.

METHOD 3 – Use a macro to update all fields in the entire document

You can update all fields anywhere in the document in one operation using a macro made for that purpose. This is most often the smartest method, at least in documents where fields may be spread across many layers in the document. If you make an update field macro available via the Quick Access Toolbar (QAT) or a keyboard shortcut, it takes only a single click to update all fields in the entire document.

Update All Fields macro — ready for use

I have created a ready-for-use macro that updates all fields in the document no matter where they are found. You can get the Update Fields macro here.

How to make sure all fields are updated when printing

If you turn ON the option Update fields before printing, all fields in the document will be updated when you print. See the illustration below.

If the option Update fields before printing is turned OFF, only field in headers and footers and the fields listed in the warm ++ group will be updated when printing.

Note that this option is a global Word option that applies to the individual user’s Word. It is not stored in the individual document. This means that you cannot rely on all users having this option set the same way unless it is managed by e.g. macros or Group Policy. 

Update fields in Word - make sure fields are updated when printing

How to stop updating fields before printing

In general, a document you print should reflect the actual content of the document. This also means that you would most often want fields to be updated when printing. There may, however, be situations where you want to print a document without fields being updated.

METHOD 1: To prevent Word from updating fields when printing, you can temporarily turn OFF the option File > Options > Display > Printing options group > Update fields before printing (see (3) in the illustration above).

METHOD 2: You can lock the fields as explained below and thereby prevent them from being updated.  

IMPORTANT NOTE: If your reason for wanting to prevent update of fields when printing is that you often see wrong data in a document when fields have been updated, you should rather check those fields. Maybe they are not set up correctly for the purpose. I have seen examples where more or less random fields had been copied from other documents without the user updating them in the new document. The fields were indeed wrong in the context. When the fields were updated during print, they revealed undesired field results. Instead of fixing the fields, the user wanted to prevent them from being updated when printing. Instead, the problem should be solved by correcting the fields.

How to prevent fields from being updated – locked fields

There may be situations when you want to prevent the result of a field from being updated. You can obtain this by locking the field. Locked fields will not change even if you update fields:

  • Press Ctrl+F11 to lock selected fields
  • Press Ctrl+Shift+F11 to unlock selected fields

Another way of retaining the current field result is to convert the field to normal text. If you are sure you will never want a specific field to update, you can convert the field to normal text by pressing Ctrl+Shift+F9.

Locking fields within INCLUDETEXT fields by using the ! switch

Fields of the type INCLUDETEXT inserts the text and graphics contained in the document specified in the field code. You can insert the entire document or a bookmarked portion of the document.

The content inserted as the field result of an INCLUDETEXT field may include other fields. For example, cross-reference fields and other types of fields could be found.

You can add the ! switch to the INCLUDETEXT field code to prevent Word from updating fields in the inserted text unless the fields are first updated in the source document.

Example of using the ! switch

A field with the following field code will insert the content from the document «My Document.docx»:

{ INCLUDETEXT «C:\Users\MyName\Documents\My Document.docx» }

Note the double backslashes, \, instead of single backslashes, , in the file path.

If the inserted content includes fields, those fields will be updated when the INCLUDETEXT field is updated in the target document. That is the default behavior.

Let’s say a cross-reference field in the source document shows «My heading text». However, the heading it points to has been changed to «My new heading text» without updating the cross-reference field. The result in the INCLUDETEXT field will show «My new heading text» when you update the INCLUDETEXT field because that also updates fields within the field result.

You can prevent such fields inside the content from being updated if you add the ! switch (backslash + exclamation mark) to the INCLUDETEXT field as shown below:

{ INCLUDETEXT «C:\Users\MyName\Documents\My Document.docx» ! }

In other words, the ! switch added to an INCLUDETEXT field will make sure that fields inside the inserted content show the same values as in the source document, no matter whether the fields in the source document are updated. If you update the fields in the source document and then update the INCLUDETEXT field in the target document, the fields in the inserted content will be updated.

TIP: If you select IncludeText as the field name in the Field dialog box, turning on Prevent fields from being updated will add the ! switch.

Related information

You can get my Update All Fields macro here.

See the Microsoft article List of field codes in Word for information about the individual types of Word fields, their syntax and how to use them.

The Microsoft support article Some fields are updated while other fields are not lists fields that are updated automatically or updated e.g. when selecting Print Preview. However, the lists don’t seem to be complete according to my experiments. In the lists above, you will see that more fields are listed in those categories than in the Microsoft article.

By default, Word has a number of keyboards shortcuts related to fields. Knowing those shortcuts can save you a lot of time. See my article about useful shortcuts related to fields.

For details about cross-reference fields, see my article How cross-reference fields in Word work on my website wordaddins.com.

In case of problems with cross-reference fields not being updated as expected, see my article Cross-reference Problems — Troubleshooting.

Like this post? Please share to your friends:
  • Updates to microsoft word
  • Union vba excel описание
  • Use chose and choose in a sentence for each word
  • Updates for microsoft excel
  • Union query in excel