logo MakeOfficeWork.com
Search Office Sites
Powered by Microsoft Bing™

Bookmarks: Their Full Power

When you create a cross-reference to text enclosed in a bookmark that you created in the active document as described in Bookmarks: The Basics or to the text enclosed in a hidden bookmark that Word creates for a heading, numbered item, figure caption, or table caption, Word creates a REF field containing the name of the bookmark. When you create cross-references through the user interface, you do not need to know anything about the REF and other fields that underlie them. However, a little knowledge about these fields can enable you to start taking advantage of the numerous options that they offer.

You can see the REF field underlying a cross-reference by placing your cursor within the text that appears in it and pressing Shift+F9, which displays the underlying field code instead of the bookmarked text.

For example, if you create a bookmark that encloses the name of a product, such as the word keyboard, and assign the name ProductName to the bookmark, and then you create a cross-reference configured as a hyperlink to this bookmark within a sentence somewhere else in your document, the word keyboard will appear at the cross-reference.

Today I bought a new keyboard.

Now if you place your cursor within the word keyboard and press Shift+F9, Word will display the underlying field code instead of the word keyboard.

Today I bought a new { REF ProductName \h }.

This field code consists of the field name REF, the bookmark name ProductName, and the switch \h, which indicates that the cross-reference is configured as a hyperlink. When you place your cursor over a cross-reference configured as a hyperlink and click Ctrl+click, your cursor will jump to the location of the bookmark. Now, if you only need this cross-reference to display the text enclosed by the bookmark and you have no need for the hyperlink, you can delete the switch \h. You can also delete the field name REF, since REF is the default field name in Word. However, the field name REF becomes necessary if the name of your bookmark happens to be identical to the name of a Word field, such as Title.

Now, all that remains in your field code is the bookmark name, and that is all that is needed to display the bookmarked text anywhere in your document. To see this, with your cursor still inside the field code, press F9 to update the information stored by Word and display the field code result, and then type some more text that includes the bookmark name in the place where you want the bookmarked text to appear, as in the following example.

Today I bought a new keyboard, because my old ProductName stopped working properly.

Next, select the bookmark name and press Ctrl+F9, which adds the special curly brackets for field codes to the selected text and thereby transforms your bookmark name into a field code.

Today I bought a new keyboard, because my old { ProductName } stopped working properly.

Finally, with your cursor still inside the new field code, press F9 to update the information stored by Word and display the field code result. You have just learned the basic technique for using REF fields to display the same word, phrase, or other content at multiple locations in your document. There are other ways to create multiple cross-references to the same bookmark. One is to simply select and copy a cross-reference to the clipboard and paste it at other locations in your document. However, one of the purposes of this exercise was to introduce you to the possibility of manually creating and modifying field codes. When you know exactly which field codes and switches are needed for your purposes, the manual technique can often be the fastest and simplest.

If you would change the text enclosed by the ProductName bookmark to the name of another product, for example, a mouse, as described in Changing the Text Associated with a Bookmark, and if you would press Ctrl+A to select the main body of your document and then press F9, the new product name would replace the old product name in all of the cross-references to the ProductName bookmark in the main body of your document.

Today I bought a new mouse, because my old mouse stopped working properly.

Inserting REF fields for bookmarked text is not the only way to repeat updatable text in multiple locations in a document. You can also accomplish this using document properties and content controls (introduced in Word 2007). For further details, see Repeating Data by Greg Maxey.

For more information about the REF field, see the Microsoft Help topic Field Codes: Ref Field.

Cross-References that Use Other Fields

Not all cross-references are REF fields. In fact, not even all cross-references to bookmarks are REF fields. When you create a cross-reference to a bookmark and select Page number in the Insert reference to drop-down list, Word creates a PAGEREF field containing the name of the bookmark. Thus, you can easily change a cross-reference to a bookmark that shows the text enclosed by it to a cross-reference to the number of the page on which the same bookmark is located by placing your cursor within the cross-reference, pressing Shift+F9, changing the field name from REF to PAGEREF, and pressing F9. In the same manner, you can change a cross-reference to the number of the page on which a bookmark is located to a cross-reference to the same bookmark that shows the text enclosed by it by changing PAGEREF to REF. Since both of these fields support the \h and \p switches, you do not need to change or delete these switches.

Similarly, when you insert a cross-reference to an existing footnote or endnote, that is, an additional reference mark to the footnote or endnote, Word creates a NOTEREF field containing the name of the hidden bookmark that Word creates for the footnote or endnote. If the reference mark in your cross-reference and the original reference mark have different formatting, add the \f switch to apply the Footnote Reference or Endnote Reference style to the reference mark in the cross-reference. To do this quickly, place your cursor immediately before the reference mark, press Shift+F9, type a space and \f at the end of the existing field code within the curly brackets, and press F9. For more information about the NOTEREF field, see the Microsoft help topic Field Codes: NoteRef Field.

The STYLEREF field is similar to the REF field, but refers to text formatted with a specified style, rather than the text enclosed within a specified bookmark. This means that you can create cross-references to text or other content by applying a specific style to it instead of creating a bookmark for it. For more information about the STYLEREF field, see the Microsoft help topic Field Codes: StyleRef Field and Useful StyleRef Tricks by Suzanne Barnhill.

Inserting the Contents of Bookmarks from Other Documents

Just as you can use REF fields to repeat the content of a bookmark in multiple places in a document, you can use the INCLUDETEXT field to insert a bookmark with the text and graphics that it encloses from another document. For example, the following field code will insert the ProductName bookmark and its contents into the active document and will thus display the bookmarked text in the active document.

{ INCLUDETEXT "D:\\WordFiles\\MyBookmarks.docx" ProductName }

Including a bookmark in this field is optional. If no bookmark is specified, the INCLUDETEXT field will insert the entire document specified. Note that the curly brackets surrounding the field code represent the special curly brackets for field codes, which you can create by selecting the applicable field codes and pressing Ctrl+F9. Note also that the full path of the file with a double slash (\\) for each slash that ordinarily appears in a file path must be included. It is also advisable to always enclose the file name in quotation marks (""), because they are needed when the file name or folder name contains a space. This way you will remember to type the quotation marks when you really need them.

Cross-References to Numbers, Dates, and Times

Cross-references to numbers, dates, and times can be configured to show the number or date in different formats. This can be especially useful when you want to display the same number, date, or time differently in different places in your document. In addition, cross-references to numbers can be used in calculations using a =(formula) field.

When you create a cross-reference to a bookmarked number, you can have Word show the bookmarked number in different formats by using the Numeric format switch (\#) to specify the minimum number of digits that will be displayed and the position of the decimal point and to add commas or spaces as separators and a currency symbol.

Similarly, when you create a cross-reference to a bookmarked date and/or time, you can have Word show the bookmarked date and/or time in a different format using the Date-Time format switch (\@). For detailed information about using the Date-Time format switch (\@), see Modifying the Appearance of Field Results.

In addition, when you create a cross reference to a number or to a date or time with a Date-Time format switch that displays only a single number from the date or time, such as the day of the month or the hour, as the literal text inside a QUOTE field, you can also use the \* CardText format switch to display the number (more precisely, the integer part of the number) in words, the \*OrdText format switch to display the number as ordinal text, or the \* Ordinal format switch to add the appropriate suffix (st, nd, rd, or th) to the applicable Arabic number, and you can add the \* Caps, \* FirstCap, \* Upper, or \* Lower format switch to control capitalization. You can also use the \* Hex format switch to display the equivalent hexadecimal number and \* Roman format switch to display the number in Roman numerals.

To illustrate this for a number, type the number 45.95, select it, and create a bookmark named Price. Then insert the following text and field codes on a new line in your document. You can easily do this by typing everything except the curly brackets and then selecting the text enclosed by each pair of curly brackets and pressing Ctrl+ F9.

The price is { Price \# $0.## } or about { QUOTE { Price } \* CardText } dollars.

Then select the entire line and press F9. You should observe the following result.

The price is $45.95 or about forty-six dollars.

Notice that you have created two very different expressions for the same bookmarked number.

To illustrate this for a date, type the date July 4, select it, and create a bookmark named TheDate. Then insert the following text and field codes on a new line in your document. As in the previous example, you can easily do this by typing everything except the curly brackets and then selecting the text enclosed by each pair of curly brackets and pressing Ctrl+ F9.

The { QUOTE { TheDate \@ d } \* OrdText \* FirstCap } of { TheDate \@ MMMM }.

Then select the entire line and press F9. You should observe the following result.

The Fourth of July.

For more detailed information about these and some more format switches, see Insert and Format Field Insert and Format Field Codes in Word 2010 or Insert and Format Field Insert and Format Field Codes in Word 2007.

Creating a Cross-Reference to a Range of Pages

When you create a hyperlinked cross-reference to the page of a bookmark named MyBookmark1, Word creates the following field code.

{ PAGEREF MyBookmark1 \h }

You can see the field codes of any cross-reference by placing your cursor in it and pressing Shift+F9.

You can create a range of pages in your case by creating a second bookmark, for example, Bookmark2, at the end of the text enclosed by the first bookmark and adding a dash followed by a cross-reference to the second bookmark. You would then have the following with the field codes displayed;

{ PAGEREF MyBookmark1 \h }-{ PAGEREF MyBookmark2 }

In this case the range of pages will appear even if the bookmarked text is all on one page.

You can use an IF field to make the range appear only when the bookmarked text spans more than one page. An IF statement contains a condition followed by two possible results surrounded by quotation marks (""). The first result is for when the condition is true, and the second result is for when the condition is false. Here we will use a condition that the page numbers of the two bookmarks are the same. If this condition is true, no additional text should appear. If the condition is false, a hyphen (-) followed by the page number of the second bookmark should appear. The field codes would then be as follows:

{ PAGEREF MyBookmark1 \h }{IF{ PAGEREF MyBookmark1 } =
{ PAGEREF MyBookmark2 } "" "-{ PAGEREF MyBookmark2 }" }

Since the curly brackets in fields codes are not ordinary curly brackets, to create this code manually, you can copy and paste the additional PAGEREF fields from the existing ones, add the other text, and then select everything from IF to the last " and press Ctrl+F9.

After you do this for one cross-reference, you can save the field codes as AutoText and reuse it for other cross-references. You will then only need to select the inserted AutoText, press Shift+F9, change the names of the bookmarks as required, and press F9.

Adding a Bookmark in a SET Field

Sometimes you may want to add a bookmark that encloses text without displaying the text enclosed by the bookmark at the location of the bookmark. This can be done by inserting a SET field with a name for the new bookmark and the bookmarked text. The bookmarked text can then be repeated anywhere in your document by inserting a cross-reference to it, but the text in the original bookmark is invisible. Bookmarks created in a SET field appear in the list of bookmarks just like ordinary bookmarks.

Bookmarks created in a SET field can be useful in the following situations.

  • For typing a number, date, or time in the simplest format and displaying it with a specific format in multiple locations in your document
  • For defining a number that is never displayed in your document for use in calculations in =(formula) fields
  • For creating an expression containing cross-references for use as a nested formula in =(formula) fields
  • For defining an expression for use in IF fields
  • For creating a list of invisible bookmarked variables in a single place that can be used in the same manner as document variables for repeating the bookmarked text throughout your document
  • For creating a series of bookmarks that hold the names of other bookmarks for use in a cross-reference (REF field) to a bookmark that encloses the name of one of the bookmarks in the series

As in the case of an ordinary bookmark, when you use a SET field, you can change the text once in the SET field and have Word change it in all the cross-references to it without searching and replacing through the entire document.

As an illustrative example, insert the following text and field codes into a document. You can easily do this by typing everything except the curly brackets and then selecting the text enclosed by each pair of curly brackets and pressing Ctrl+ F9.

{ SET CmInch "2.54" }A 1.27 cm margin is equal to a { =(margin / CmInch) } inch margin.

Select 1.27 and create a bookmark named margin. Then select the entire line and press F9. You should observe the following result.

A 1.27 cm margin is equal to a 0.5 inch margin.

Notice that the conversion factor 2.54 is invisible to the reader and that the use of the =(formula) field provides the correct value without the need to perform any calculation. You can now change the bookmarked margin size in centimeters, click 0.5, press F9, and obtain the margin size in inches for another metric margin size.

Notice also that the bookmark names margin and CmPerInch within the =(formula) field are cross-references to the respective bookmarks even though they are not enclosed in curly brackets and the field name REF is absent.

If you are creating a template, you can insert an ASK field, which will act just like a SET field with one important difference. When a new document is created from the template, a pop-up will appear to let the user supply the text that will be enclosed by the invisible bookmark created in the ASK field.

For more information about the SET field, see the Microsoft Help topic Field Codes: SET Field. For more information about the ASK field, see the Microsoft Help topic Field Codes: ASK Field.

Shortcut Keys for Working with Field Codes

The following table lists the shortcut keys that can make working with field codes much simpler, faster, and easier. Most of these shortcut keys were used in the various sections on this page, and a few others are included for the sake of presenting a complete list.

Shortcut keys for use with field codes
Key Action
Ctrl+A Selects all.
F9 Updates the field at the cursor or all fields in the current selection. If Alt+F9 has not been pressed to show all field codes, this key also shows the field code result instead of the field code for the field code at the cursor or all field codes that are shown in the selection.
Ctrl+F9 Converts the selected text to a field code and adds the special curly brackets that are part of the field code.
Shift+F9 Shows or hides the selected field codes or the field code at the cursor.
Alt+F9 Shows or hides all field codes.
Ctrl+Shift+F9 Deletes the field code and leaves the current result.
Alt+Shift+F9 Performs a click on the field.
F11 Moves to the next field.
Ctrl+F11 Locks the selected fields to prevent updating (same as Ctrl+3).
Shift+F11 Moves to the previous field.
Ctrl+Shift+F11 Unlocks the selected fields to enable updating (same as Ctrl+4).

More Information

For more information about the syntax of field codes, see the Microsoft help topic Insert and Format Field Codes in Word 2010 or Insert and Format Field Codes in Word 2007 according to your version of Word. For information about specific field codes, see Field Codes in Word (for Word 2010) or Field Codes in Word (for Word 2007).

Quick Reference for this Page

After an introduction that describes the REF field that Word creates for cross-references to bookmarked text in the same document, this page describes the field codes used in cross-references to other types of targets in the same document, the field code used for inserting the content of a bookmark from another document, additional things that can be done with cross-references to numbers, dates, and times, creating a cross-reference to a range of pages, adding an invisible bookmark in a SET field, and the shortcut keys for working with field codes.

Search Office Sites

You can search the websites that have the most useful and valuable information about using Microsoft Office products by using the Search Office Sites search box in the banner. Click to start your search.

Other Resources