Insert or update a field code

Fields in Word are used as placeholders for data that might change in a document and for creating form letters and labels in mail-merge documents. Fields, also known as field codes, are different from the type of fields that are used to enter information, such as on a form. Word automatically inserts fields when you use particular commands, such as when you insert a page number, a document element such as a cover page, or when you create a table of contents. You can also manually insert fields to automate aspects of your document, such as merging data from a data source or performing calculations. However, in most cases it is easier to use the commands and options that are provided in Word to add the information that you want. For example, you can insert a hyperlink by using the HYPERLINK field, but it is easier to use the Hyperlink command on the Insert menu.

Field codes appear between curly brackets { }. A field behaves like a formula in Excel — the field code is like the formula (which is hidden), and the field result is like the value that the formula produces (which is visible). You can switch between displaying field codes and results in your document by pressing OPTION + F9 . When you view a field code in your document, the syntax looks like this: { FIELD NAME Properties Optional switches }.

Syntax

Description

FIELD NAME

The name that appears in the list of field names in the Field dialog box.

Properties

Instructions or variables that are used in a particular field. Not all fields have parameters, and in some fields, parameters are optional instead of required.

Optional switches

Optional settings that are available for a particular field. Not all fields have switches available, other than those that govern the formatting of the field results.

For example, you can place the file name and path of your document in the header or footer by inserting the FILENAME field. The syntax for the FILENAME field code with the path that is included looks like this: { FILENAME \p }

Do any of the following:

Insert a field

Click where you want to insert a field.

On the Insert menu, click Field.

In the Field names list, select the field that you want to insert.

To set any additional switches for the field, click Options, select a switch, click Add to Field, and then click OK.

Notes:

Because field codes can be visible to anyone reading your document, be sure that the information you place in field codes is not information that you want kept private.

To nest a field within another field, first insert the outer (or container) field by using the Field dialog box. In your document, place the insertion point inside the field code where you want to insert the inner field. Then use the Field dialog box to insert the inner field.

You cannot insert field code brackets by typing the brace characters on the keyboard. To insert field code brackets, press
+ F9 , and then type the code within the brackets.

Update an individual field

By default, Word automatically updates fields when a document is opened. That way, information stays up to date. Rather than quitting and then reopening Word to update a field, you can update an individual field while you're still working in the document.

Press CONTROL , click the field, and then click Update Field.

Update all fields when you print

You can have Word automatically update all fields when you print a document.

On the Word menu, click Preferences.

Under Output and Sharing, click Print
.

Under Printing options, select the Update fields check box.

Lock or unlock a field

You can prevent Word from automatically updating a field by locking it. For example, you may want the date field in the header to reflect a particular date rather than automatically updating to the current date every time the document is opened.

Do one of the following:

To

Do this

Lock a field

Click the field and press
+ F11 .

Unlock a field

Click the field and press
+ SHIFT + F11 .

Change the shaded background of fields

By default, Word displays the field results seamlessly with the content of your document so that someone who reads the document cannot see the field contents. However, you can specify whether to display the fields with a shaded background to make them more visible.

On the Word menu, click Preferences.

Under Authoring and Proofing Tools, click View
.

Under Show, on the Field shading pop-up menu, select the option that you want.

Apply text formatting to a field

You can apply text formatting to a field, just as you would any other text.

Select the field that you want to format.

On the Home tab, under Font, apply the formatting that you want.

For example, to underline the name that is inserted by an AUTHOR field, select the entire field code, including brackets (or select the entire field result), and then click Underline
.

Note: If you update a field, any formatting that you applied to the field results may be lost. To retain the formatting, include the \* MERGEFORMAT switch in the field code. When you insert fields by using the Field dialog box, the \* MERGEFORMAT switch is included by default.