Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

The StyleRef field inserts text that's formatted with the specified style. When inserted in a header or footer, the StyleRef field prints the first or last text formatted with the specified style in the document body of the current page, allowing you to print dictionary-style headers or footers.

Syntax

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

{ STYLEREF StyleIdentifier [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

StyleIdentifier

Name of the style used to format the text you want to insert. The style can be a paragraph style or a character style. If the style name contains spaces, enclose it in quotation marks.

Switches

\l

Inserts the last text formatted with the style on the current page instead of the first text formatted with this style. Microsoft Word searches the page for the style from bottom to top instead of from top to bottom (the default).

\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 StyleRef field appears in the document before the bookmark, it evaluates to "below."

If the StyleRef field appears after the bookmark, it evaluates to "above."

If the StyleRef field appears within the bookmark, an error is returned.

\r

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

\t

When used with the \n, \r, or \w switch, causes the StyleRef field to suppress nondelimiter, or nonnumerical, text.

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 StyleRef field with the \w switch would return "1.a.ii" as a result.

Examples

If inserted in a header, the following field displays the contents of the first paragraph formatted with the style "Heading 3" on the current page.

Field:

On this page: { STYLEREF "Heading 3" }

Result:

On this page: Summary of Sales by Region

To print the first and last names that appear on each page in the membership directory for your organization, first apply a character style to each member's last name. Then insert StyleRef fields in the header. The second StyleRef field includes the \l switch, which inserts the last name on the page.

Field:

{ STYLEREF "Last Name" } — { STYLEREF "Last Name" \l }

Result:

Ackerman — Berg

StyleRef field location

Where you insert the StyleRef field determines the direction that Word searches for the style and thus can affect which text is inserted.

When you insert the field in:

  • Document text: Word searches backward from the StyleRef field for the specified style. If the style isn't found, Word searches forward from the StyleRef field.

  • Footnotes, annotations, and endnotes: Word searches backward from the footnote, annotation, or endnote reference mark for the specified style. If the style isn't found, Word searches forward from the reference mark.

  • Headers and footers (results for printed document): Word searches the current page, from top to bottom, for the specified style. If the style isn't found, Word searches next from the top of the page to the beginning of the document, and then from the bottom of the page to the end of the document. If the \l switch is used, Word searches from the bottom of the page to the beginning and then to the end of the document.

  • Headers and footers (results for electronic document): Word searches the section that contains the StyleRef field, from the beginning, for the specified style. If the style isn't found, Word searches from the end of the section to the end of the document.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×