Updating Fields in Word – How it Works
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 cold, warm, 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:
Selection.Fields(1).Kind
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 |
A field that doesn’t have a result. This also means that a cold field includes nothing to be updated. |
PRIVATE |
Warm |
|
2 |
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) |
Warm ++ |
|
2 |
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 |
Hot |
|
1 |
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 |
None |
|
0 |
An invalid field such as an empty field. If you create fields manually, you can start with an empty field. Examples of invalid fields: |
(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 |
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 |
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 |
|
|
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:
- Press Ctrl+F9 to add an empty field.
- 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. - 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
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
- 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. - 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.
- To quickly switch to Print Preview, press Alt+Ctrl+I.
- 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 fields 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.
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:
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.