Field codes: Ref field

The Ref field inserts the text or graphics represented by the specified bookmark. The bookmark must be defined in the active document. To insert bookmarked text or graphics from another document, use the IncludePicture or IncludeText field. The Cross-reference command (Insert tab, Links group) inserts Ref fields to create cross-references.

In most cases, you can use the bookmark name instead of the Ref field. Using the Ref field is optional except in cases where a bookmark name matches a Microsoft Word field name. For example, if the bookmark name is "Title", which matches the Word field name Title, you must use the Ref field instead of the bookmark name. The field { REF Title } inserts the text represented by the "Title" bookmark, whereas the field { Title } inserts the contents of the Title box on the Summary tab in the Properties dialog box.

Note   When you insert text copied from another location in the same document, the Paste Special command (Home tab, Clipboard group, Paste command) inserts a Ref field with the bookmark INTER_LINKn, where n is incremented automatically. You should not edit an INTER_LINKn bookmark in a Ref field. Also note that Ref fields with INTER_LINKn bookmarks in a mail merge main document can cause errors during merging.

Syntax

When you view the Ref field in your document, the syntax looks like this:

{ [REF] Bookmark [Switches ] }

Note    A field code tells the field what to show. Field results are what’s shown in the document after having evaluated the field code. To toggle between viewing the field code and the field code results, press Alt+F9.

Instructions

Bookmark

The name of a bookmark. If the text marked by the bookmark contains a paragraph mark, the text preceding the REF field assumes the formatting of the paragraph in the bookmark.

Switches

\d

Specifies the characters that separate sequence numbers (such as chapter numbers) and page numbers.

\f

Increments footnote, endnote, or annotation numbers that are marked by the bookmark and inserts the corresponding note or comment text. For example, the bookmark "Note1" marks the reference mark of footnote 1. The field { REF Note1 \f } is inserted after footnote 2. The field result displays the footnote reference mark "3" in the document text and inserts the text of footnote 1 into the footnote window.

\h

Creates a hyperlink to the bookmarked paragraph.

\n

Causes the field to display the entire paragraph number for a referenced paragraph without trailing periods. No information about prior levels is displayed unless it is included as part of the current level.

\p

Causes the field to display its position relative to the source bookmark using the word "above" or "below."

If the REF field appears in the document before the bookmark, it evaluates to "below." If the REF field appears after the bookmark, it evaluates to "above." If the REF field appears within the bookmark, an error is returned.

This switch can also be used in conjunction with the \n, \r, and \w switches. When this is done, "above" or "below" is appended to the end of the field result.

\r

Inserts the entire paragraph number of the bookmarked paragraph in relative context — or relative to its position in the numbering scheme — without trailing periods.

\t

Causes the REF field to suppress non-delimiter or non-numerical text when used in conjunction with the \n, \r, or \w switch.

With this switch, for example, you can reference "Section 1.01," and only "1.01" is displayed in the result.

\w

Inserts the paragraph number of the bookmarked paragraph in full context from anywhere in the document.

For example, when referencing paragraph "ii.," a REF field with the \w switch would return "1.a.ii" as a result.

Examples

The following REF field assigns the result of an ASK field that prompts the user for the cost per unit. The ASK field prompts the user for information when the field is updated and then assigns the user's input to the bookmark "unitcost":

{ ASK unitcost "What's the cost per unit?" }

{ REF unitcost }

Applies To: Word 2010, Word 2016 Preview, Word 2013



Was this information helpful?

Yes No

How can we improve it?

255 characters remaining

To protect your privacy, please do not include contact information in your feedback. Review our privacy policy.

Thank you for your feedback!

Support resources

Change language