Field codes: StyleRef field

Microsoft Office Word 2003

StyleIdentifier [Switches ] }

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 on the current page, allowing you to print dictionary-style headers or footers.

ShowInstructions

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.

ShowSwitches

\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.

ShowExamples

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:

Anders— Bendal

STYLEREF field location

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

When you insert the field in:

ShowDocument 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.

ShowFootnotes, 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.

ShowHeaders 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.

ShowHeaders 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.