Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

 
 
Microsoft Office Word
Search
Search
 
Check for updates: (c) Microsoft
Office downloads
 
 
 
Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Email this linkEmail this link Printer-Friendly VersionPrinter-Friendly Version Bookmark and ShareShare
Field codes: StyleRef field
 

{ STYLEREF StyleIdentifier [Switches ] }

Inserts text that's formatted with the specified style (style: A combination of formatting characteristics, such as font, font size, and indentation, that you name and store as a set. When you apply a style, all of the formatting instructions in that style are applied at one time.). When inserted in a header or footer (header and footer: A header, which can consist of text or graphics, appears at the top of every page in a section. A footer appears at the bottom of every page. Headers and footers often contain page numbers, chapter titles, dates, and author names.), 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.

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 (bookmark: A location or selection of text in a file that you name for reference purposes. Bookmarks identify a location within your file that you can later refer or link to.) 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 (character style: A combination of any of the character formatting options identified by a style name.) 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 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 (section: A portion of a document in which you set certain page formatting options. You create a new section when you want to change such properties as line numbering, number of columns, or headers and footers.) 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.

advertisement