Insert Fields in a Microsoft Word Document to Display Variable Content
by Avantix Learning Team | Updated January 10, 2021
Applies to: Microsoft® Word® 2010, 2013, 2016, 2019 or 365 (Windows)
You can insert built-in or custom fields in Word documents to display variable content that will change when you update the fields. Some fields (like page numbers, merge fields or cross-references) are inserted automatically when you use Microsoft Word features. If you want to insert custom fields, you will need to create custom document properties.
By default, Word displays the result of a field rather than its field codes. You can right-click a field and select Toggle Field Codes to display field codes or field results.
Recommended article: How to Hide Comments in Word (or Display Them)
Do you want to learn more about Microsoft Word? Check out our virtual classroom or live classroom Word courses >
If you are working with fields in Microsoft Word, you will be using quite a few function keys (such as F9). On some laptops, you will need to press the Fn key on your keyboard to enable your function keys. For example, instead of pressing F9 to update a field or fields, you would press Fn + F9.
Inserting built-in fields
To insert a field, click Quick Parts in the Text group on the Insert tab in the Ribbon. The Field command appears in the Quick Parts drop-down menu as follows:
Below is the Field dialog box in Microsoft Word with Page selected:
To insert a built-in field using the Field dialog box:
- Navigate to the location in the Word document where you want to insert a field.
- Click the Insert tab in the Ribbon and then click Quick Parts in the Text group. A drop-down menu appears.
- Select Field. A dialog box appears.
- In the list of Field names, select a field. You can filter the list by clicking the down arrow in the Categories list and selecting a category first. Select All to display all fields.
- Under Field properties, select any properties or options you want.
- To view the codes for a field in the Field box, click Field Codes. For some fields, this button is clicked by default.
- Ensure that Preserve Formatting During Updates is checked so that formatting you apply is not removed when the fields are updated.
- Click OK. The field is inserted into the document.
Format the field results by applying text formatting to the field using the Home tab in the Ribbon.
You can view or hide all field codes in your document by pressing Alt + F9. Field codes appear between braces or curly brackets { } and you cannot type these braces. Be sure to hide the field codes again by pressing Alt + F9.
To edit a built-in field in the Field dialog box:
- Right-click the field and then click Edit Field. A dialog box appears.
- Change the field properties and options.
- Click OK.
Understanding Word document properties
There are 3 different types of document properties in Word:
- Standard document properties (also called built-in document properties)
- Custom document properties
- Document library properties
Word documents contain a set of standard document properties such as Title, Author, Keywords and Comments. These properties are used to store metadata about your document. You cannot change the name of standard properties but you can edit the value of some of them (such as Title). Other standard properties that cannot be edited store data that is updated automatically (such as Size or Last Modified).
Document library properties are related to documents that are stored in a document library on a website or in a public folder (such as files in SharePoint).
In addition to the standard properties, you can create your own custom document properties. These properties can be created to store additional information in a document other than the standard document properties. For example, custom document properties could be created for Product1, Product2, Product3, Sponsor, Project Manager, Cell Phone or Disclaimer. Each custom document property must be assigned a name, a data type and a value. The four data types are Text, Date, Number and Yes or No.
After you create custom document properties for your Word document, you can then insert them as custom fields.
Adding a custom document property
To add a custom document property:
- Open the Word document in which you want to add a custom document property.
- Click the File tab in the Ribbon and then click Info on the left. Info is usually selected by default.
- On the right side of screen, click Properties. A drop-down menu appears.
- Select Advanced Properties. A dialog box appears.
- Click the Custom tab in the dialog box.
- Type a name for the custom document property in the Name box. You can also choose one of the other properties that appear in the drop-down list.
- Select Text, Date, Number or Yes or No as the data type for the custom property.
- Enter a value for the property in the Value box.
- Click Add. The custom property appears in the list at the bottom of the dialog box.
- Click OK.
After you have added a custom document property, you will be able to insert it into your document as a field.
In the example below, we’re adding a field for Project Manager:
After you click Add, the custom field appears in the Properties list:
Inserting custom document property fields
The value of a custom document property can be inserted in a Word document using DocProperty fields. Custom document properties that have been added to a document are saved with the document whether they are inserted as a DocProperty field or not. You can insert DocProperty fields multiple times in a document.
To insert a custom document property field using the Field dialog box:
Navigate to the location in the Word document where you want to insert a field.
- Click the Insert tab in the Ribbon and then click Quick Parts in the Text group. A drop-down menu appears.
- Select Field. A dialog box appears.
- In the list of Field names on the left, select DocProperty.
- Under Field properties, select a property name.
- To view the codes for a field in the Field box, click Field Codes. For some fields, this button is clicked by default.
- Ensure that Preserve Formatting During Updates is checked so that formatting you apply is not removed when the fields are updated.
- Click OK. The field is inserted into the document.
In the example below, we’re inserting the custom Project Manager field we created in Advanced Properties:
Updating built-in and custom fields
Word should automatically update fields when a document is opened. Many fields are also updated automatically when you go to Print Preview (click the File tab and then click Print). If you prefer, you can update fields manually.
To update a field manually, right-click the field and then click Update Field or press F9.
To update all fields manually in the main body of a document, press Ctrl + A to select all and then press F9.
Some fields in headers, footers or text boxes must be updated separately. Click in the header, footer or text box, press Ctrl + A to select all and then press F9. Page fields do not need to be updated manually because they update when you go the Print Preview.
If you want to edit a custom DocProperty field, you will need to edit it in the Advanced Properties dialog box.
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 Create, Save, Edit and Use Templates in Word
How to Insert, Format and Update Cross-References in Word
5 Ways to Insert the Division Symbol in Word (Type or Insert ÷)
10 Microsoft Word Tips, Tricks and Shortcuts for Selecting in Tables
How to Create a Table of Contents in Word (Insert, Format and Update a TOC)
Related courses
Microsoft Word: Intermediate / Advanced
Microsoft Excel: Intermediate / Advanced
Microsoft PowerPoint: Intermediate / Advanced
Microsoft Word: Long Documents Master Class
Microsoft Word: Styles, Templates and Tables of Contents
Microsoft Word: Designing Dynamic Word Documents Using Fields
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
on
September 8, 2021, 8:17 AM PDT
3 ways to enter fields in Microsoft Word
Microsoft Word fields house instructions that help you create dynamic content; they’re flexible and powerful, if you know how to use them.
We may be compensated by vendors who appear on this page through methods such as affiliate links or sponsored partnerships. This may influence how and where their products appear on our site, but vendors cannot pay to influence the content of our reviews. For more info, visit our Terms of Use page.
Occasionally, a requirement simply can’t be easily met with the built-in features. Microsoft Word fields are similar to little bits of code that have a specific job. They return values that you can’t easily do in Word any other way. Fortunately, they’re easy to use once you get the hang of entering them properly. In this article, I’ll show you three ways to enter a Word field:
- Use the interface
- Ctrl + F9
- Type and convert
I’m using Microsoft 365 on a Windows 10 64-bit system, but you can use earlier versions. Word fields aren’t supported by Word Online; the original values will display, but they won’t update, nor can you enter them.
SEE: 83 Excel tips every user should master (TechRepublic)
About Word fields
You can insert fields to display content that will change when you update those fields. You might not realize it, but you’re already using fields. Page numbers, merge fields and so on are inserted automatically when you use those features.
You’ll notice as you work your way through the quick examples, that the function key, F9, plays a big part when working with fields. Specifically, here’s what this key does:
- Ctrl + F9 enters a blank field.
- Alt + F9 toggles all the fields in the document.
- Shift + F9 toggles the selected field.
In addition to entering and toggling fields, you can modify them using switches. A switch is an additional bit of information; it always starts with a backslash (). Switches add formats and change the field’s behavior a bit. We won’t include switches in this article, but you’ll want to explore them later.
When you enter a field, the underlying field code will use the following syntax:
{ FIELD NAME Properties Optional switches }
See Table A for an explanation of these elements.
Table A
FIELD TYPE | This is the name of the code and determines what the field does. You’ll often see this part in all uppercase letters, but it isn’t case sensitive. |
Properties | Optional instructions, but not all fields have them. In the interface dialog that you’ll see in the next section, these are referred to as Field Properties. |
Switches | These are specific instructions, often to do with formatting that you can enable or disable. The character always denotes a switch. |
When including fields in a document, remember that anyone viewing the document in Word can view the underlying codes, so be careful about including personal or confidential information. I’ve never run into this situation but it’s worth noting.
Now that you have a good feel for what fields are, let’s start inserting them. We’ll begin with the interface method.
How to insert a Word field using the interface
Word’s interface provides the most comprehensive method for inserting fields. Even if you find another method easier, I encourage you to review the interface so you can learn what fields are available and about their switches.
SEE: Windows 10: Lists of vocal commands for speech recognition and dictation (free PDF) (TechRepublic)
To enter a field using the interface, do the following:
- Position the cursor where you want to insert the field, which can be in the document body, or the header or footer.
- Click the Insert tab and then click the Quick Parts dropdown in the Text group.
- From the dropdown, choose Fields (Figure A).
- The resulting dialog lists the Word fields in the Field Names list, which you can filter using the Categories list. For this simple example, select Author and then select First Capital in the Format list as shown in Figure B.
- Click OK, and you’ll see the author’s name in the document (Figure C).
Figure A
Figure B
Figure C
You may have noticed a few other options in the dialog:
- Field Codes will display the underlying field code.
- Options will display formatting options and other specialized options that are specific to the field.
- Preserve Formatting During Updates does just what it says: it preserves formatting.
You’ll want to explore the list of fields and their many options when you have more time.
You can use the interface to nest fields. After choosing one field, move the cursor inside that field and then return to the list and choose the second field. This capability takes a bit of practice. In fact, many users find it easier to enter a nested field manually.
How to insert a Word field by typing and converting
Perhaps the easiest method to enter any field is to simply type it, select it and then press Ctrl + F9. Doing so converts the text to the field(s). Let’s try this with again, the Author field:
- Position the cursor where you want to insert the field.
- Type Author
- Select the text you just typed (Figure D).
- Press Ctrl + F9 to convert the string into a true field. As you can see, Word adds the brackets.
- To display the field value instead of the field, press F9.
Figure D
This is a quick and easy way to enter a single field when you know the field code and any switches you might want to include. You can also use this method to insert a nested field, but you must insert each individually. You can’t type out an entire string and convert all the fields at once.
How to insert a Word field by using Ctrl + F9
The third method is similar to the previous method. Press Ctrl + F9 to insert a pair of empty brackets and then type the field code and any switches. Let’s try this method with the same { Author } field:
- Position the cursor where you want to insert the field.
- Press Ctrl + F9 to enter a blank field, as shown in Figure E.
- Enter the field code Author inside the brackets and press F9 to calculate the result.
Figure E
Word displays a field’s results rather than the field code, by default. Right-clicking serves as a toggle to display the underlying field code instead of its result. Doing so converts only the one field, so this is an easy way to quickly edit only one field.
For a full list of field codes, visit List of field codes in Word.
Also See
-
How to make fewer mistakes and work more efficiently using predictive text in Microsoft 365
(TechRepublic) -
How to use the many text wrapping options in Microsoft Word
(TechRepublic) -
Microsoft 365: A cheat sheet
(TechRepublic) -
Zoom vs. Microsoft Teams, Google Meet, Cisco WebEx and Skype: Choosing the right video-conferencing apps for you (free PDF)
(TechRepublic) -
Checklist: Securing Windows 10 systems
(TechRepublic Premium) -
Must-read coverage: Windows 10
(TechRepublic on Flipboard)
-
Microsoft
-
Software
Word for Microsoft 365 Word for Microsoft 365 for Mac Word 2021 Word 2021 for Mac Word 2019 Word 2019 for Mac Word 2016 Word 2016 for Mac Word 2013 Word 2010 Word for Mac 2011 More…Less
To create a form in Word that others can fill out, start with a template or document and add content controls. Content controls include things like check boxes, text boxes, date pickers, and drop-down lists. If you’re familiar with databases, these content controls can even be linked to data.
Show the Developer tab
If the developer tab isn’t displayed in the ribbon, see Show the Developer tab.
Open a template or a blank document on which to base the form
To save time, start with a form template or start from scratch with a blank template.
-
Go to File > New.
-
In Search online templates, type Forms or the type of form you want and press ENTER.
-
Choose a form template, and then select Create or Download.
-
Go to File > New.
-
Select Blank document.
Add content to the form
Go to Developer, and then choose the controls that you want to add to the document or form. To remove a content control, select the control and press Delete. You can set properties on controls once inserted.
Note: You can print a form that was created using content controls, but the boxes around the content controls will not print.
In a rich text content control, users can format text as bold or italic, and they can type multiple paragraphs. If you want to limit what users add, insert the plain text content control.
-
Click or tap where you want to insert the control.
-
Select Developer > Rich Text Content Control or Plain Text Content Control .
To set specific properties on the control, see Set or change properties for content controls.
A picture control is often used for templates, but you can also add a picture control to a form.
-
Click or tap where you want to insert the control.
-
Select Developer > Picture Content Control .
To set specific properties on the control, see Set or change properties for content controls.
Use building block controls when you want people to choose a specific block of text. For example, building block controls are helpful when you need to add different boilerplate text depending on the contract’s specific requirements. You can create rich text content controls for each version of the boilerplate text, and then you can use a building block control as the container for the rich text content controls.
-
Click or tap where you want to insert the control.
-
Go to DeveloperBuilding Block Gallery Content Control (or Building Block Content Control).
-
Select Developer and content controls for the building block.
-
Click or tap where you want to insert the control.
To set specific properties on the control, see Set or change properties for content controls.
In a combo box, users can select from a list of choices that you provide or they can type in their own information. In a drop-down list, users can only select from the list of choices.
-
Go to Developer > Combo Box Content Control or Drop-Down List Content Control .
-
Select the content control, and then select Properties.
-
To create a list of choices, select Add under Drop-Down List Properties.
-
Type a choice in Display Name, such as Yes, No, or Maybe.
Repeat this step until all of the choices are in the drop-down list.
-
Fill in any other properties that you want.
Note: If you select the Contents cannot be edited check box, users won’t be able to click a choice.
-
Click or tap where you want to insert the date picker control.
-
Select Developer > Date Picker Content Control .
To set specific properties on the control, see Set or change properties for content controls.
-
Click or tap where you want to insert the check box control.
-
Select Developer > Check Box Content Control .
To set specific properties on the control, see Set or change properties for content controls.
Legacy form controls are for compatibility with older versions of Word and consist of legacy form and Active X controls.
-
Click or tap where you want to insert a legacy control.
-
Go to Developer > Legacy Forms drop-down.
-
Select the Legacy Form control or Active X Control that you want to include.
Set or change properties for content controls
Each content control has properties that you can set or change. For example, the Date Picker control offers options for the format you want to use to display the date.
-
Select the content control that you want to change.
-
Go to Developer > Properties.
-
Change the properties that you want.
Add protection to a form
If you want to limit how much others can edit or format a form, use the Restrict Editing command:
-
Open the form that you want to lock or protect.
-
Select Developer > Restrict Editing.
-
After selecting restrictions, select Yes, Start Enforcing Protection.
Advanced Tip:
If you want to protect only parts of the document, separate the document into sections and only protect the sections you want.
To do this, choose Select Sections in the Restrict Editing panel. For more info on sections, see Insert a section break.
Show the Developer tab
If the developer tab isn’t displayed in the ribbon, see Show the Developer tab.
Open a template or use a blank document
To create a form in Word that others can fill out, start with a template or document and add content controls. Content controls include things like check boxes, text boxes, and drop-down lists. If you’re familiar with databases, these content controls can even be linked to data.
-
Go to File > New from Template.
-
In Search, type form.
-
Double-click the template you want to use.
-
Select File > Save As, and pick a location to save the form.
-
In Save As, type a file name and then select Save.
-
Go to File > New Document.
-
Go to File > Save As.
-
In Save As, type a file name and then select Save.
Add content to the form
Go to Developer, and then choose the controls that you want to add to the document or form. To remove a content control, select the control and press Delete. You can set Options on controls once inserted. From Options, you can add entry and exit macros to run when users interact with the controls, as well as list items for combo boxes, .
-
In the document, click or tap where you want to add a content control.
-
On Developer, select Text Box, Check Box, or Combo Box.
-
To set specific properties for the control, select Options, and set .
-
Repeat steps 1 through 3 for each control that you want to add.
Options let you set common settings, as well as control specific settings. Select a control and then select Options to set up or make changes.
-
Set common properties.
-
Select Macro to Run on lets you choose a recorded or custom macro to run on Entry or Exit from the field.
-
Bookmark Set a unique name or bookmark for each control.
-
Calculate on exit This forces Word to run or refresh any calculations, such as total price when the user exits the field.
-
Add Help Text Give hints or instructions for each field.
-
OK Saves settings and exits the panel.
-
Cancel Forgets changes and exits the panel.
-
-
Set specific properties for a Text box
-
Type Select form Regular text, Number, Date, Current Date, Current Time, or Calculation.
-
Default text sets optional instructional text that’s displayed in the text box before the user types in the field. Set Text box enabled to allow the user to enter text into the field.
-
Maximum length sets the length of text that a user can enter. The default is Unlimited.
-
Text format can set whether text automatically formats to Uppercase, Lowercase, First capital, or Title case.
-
Text box enabled Lets the user enter text into a field. If there is default text, user text replaces it.
-
-
Set specific properties for a Check box.
-
Default Value Choose between Not checked or checked as default.
-
Checkbox size Set a size Exactly or Auto to change size as needed.
-
Check box enabled Lets the user check or clear the text box.
-
-
Set specific properties for a Combo box
-
Drop-down item Type in strings for the list box items. Press + or Enter to add an item to the list.
-
Items in drop-down list Shows your current list. Select an item and use the up or down arrows to change the order, Press — to remove a selected item.
-
Drop-down enabled Lets the user open the combo box and make selections.
-
-
Go to Developer > Protect Form.
Note: To unprotect the form and continue editing, select Protect Form again.
-
Save and close the form.
If you want, you can test the form before you distribute it.
-
Protect the form.
-
Reopen the form, fill it out as the user would, and then save a copy.
Show the Developer tab
-
On the right side of the ribbon, select , and then select Ribbon Preferences.
-
Under Customize, select Developer .
Open a template or a document on which to base the form
You can start with a blank document and create your own form. Or, to save time, you can start with a form template.
-
Go to File > New from Template.
-
In the left pane, expand Online Templates, and then select Forms.
-
Double-click the form template that you want to use.
Add content controls to the form
-
In the document, click where you want to add the control.
-
On the Developer tab, under Form Controls, select Text Box, Check Box, or Combo Box.
-
To set specific properties for the control, select Options, and then configure the properties that you want.
Note: To create a list of drop-down items in a combo box, select the combo box placeholder, click Options, and then add the items that you want to appear in the drop-down list.
-
Repeat steps 1 through 3 for each control that you want to add.
Add instructional text (optional)
Instructional text (for example, «Type First Name») in a text box can make your form easier to use. By default, no text appears in a text box, but you can add it.
-
Select the text box control that you want to add instructional text to.
-
On the Developer tab, under Form Controls, select Options.
-
In Default Text, type the instructional text.
-
Make sure that Fill-in enabled is selected, and then select OK.
Protect the form
-
On the Developer tab, under Form Controls, select Protect Form.
Note: To unprotect the form and continue editing, click Protect Form again.
-
Save and close the form.
Test the form (optional)
If you want, you can test the form before you distribute it.
-
Protect the form.
-
Reopen the form, fill it out as the user would, and then save a copy.
Creating fillable forms isn’t available in Word for the web.
You can create the form with the desktop version of Word with the instructions in Create a fillable form.
When you save the document and reopen it in Word for the web, you’ll see the changes you made.
Need more help?
Download PC Repair Tool to quickly find & fix Windows errors automatically
In Microsoft Word, you can insert built-in or custom fields into your Word document that may change within your document. In Word, the field feature inserts fields into your document; some fields will be inserted automatically, such as NumPages, NumWords, and Date.
What are Fields in Microsoft Word?
In Microsoft Word, a field is a placeholder for document information that can be changed. Microsoft Word displays the field result instead of the field codes.
How to add Fields to my Document?
There are various types of fields that you can add to your document; some field text will be inserted automatically, and some you have to modify in the dialog box before you add it to the document. In this tutorial, we will discuss how to add fields to your word documents.
To add text fields to your Word document, follow the steps below.
- Launch Microsoft Word
- Click anywhere on the document
- Click the Insert tab
- Click the Quick Parts button
- Click Field from the drop-down menu
- Choose a field name from the field name list.
- then, choose an option from the list on the right.
- Click OK
Launch Microsoft Word
Click anywhere on the Word document.
On the menu bar, click the Insert tab.
In the Text group, click the Quick Parts button.
Then select Field from the drop-down menu.
A Field dialog box will appear.
Inside the dialog box, there are various fields to choose from in the Field Name list.
Select a field from the Field Name list on the left.
In this tutorial, we chose to select the Date field.
Then, choose a field option from the list on the right.
Depending on the field name selected, the options on the right will change.
Then click OK.
The field is added to the Word document.
If you want to change the format of the field, you cannot change it directly on the Word document; you have to change it within the Field dialog box.
To change the format of the field, right-click the field and select Edit Field.
It will return to the Field dialog box, where you can change the format of the field and then click OK to see the field change.
We hope this tutorial helps you understand; how to insert a text field in Microsoft Word; if you have questions about the tutorial, let us know.
Shantel has studied Data Operations, Records Management, and Computer Information Systems. She is quite proficient in using Office software. Her goal is to become a Database Administrator or a System Administrator.
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:
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: 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 |
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
- Text box
- Callout
- Comment
- Footnote
- Endnote
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
- 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 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.
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.