WD: How to Use the STYLEREF Field in Microsoft Word

This article was previously published under Q141994
This article has been archived. It is offered "as is" and will no longer be updated.
SUMMARY
This article describes how to use the STYLEREF field. The STYLEREF fieldcan be used to create a dictionary-style entries at the top of each page orto place the chapter title in the heading. This field is useful when youwant text in the header to match what's typed on the page.
MORE INFORMATION
The STYLEREF field is a specialized reference field designed to let you addinformation to a document, especially in the header or footer,automatically.

The STYLEREF field consists of the field, the name of the style assigned tothe text to be returned as the result of the field, and field switches.
{STYLEREF "StyleName"}
{STYLEREF "StyleName" <switches>}

NOTE: The name of the style must be enclosed in quotation marks.
Word will search the page from top to bottom (by default) for the nearestparagraph formatted with the style specified in the STYLEREF field. Wordwill return that text in the location of the field as the result.

STYLEREF Field Switches

\l - Inserts the last text formatted with the style on the current page     instead of the first text formatted with this style. Word searches     the page from bottom to top.     The \l switch is available only in headers and footers.\n - Inserts any paragraph numbering from the referenced paragraph. For     example, caption numbering is included if caption numbering has been     applied to the paragraph.				
The STYLEREF field is most often used in headers and footers. The examplesin the "Examples" section of this article illustrate the possible uses ofthe STYLEREF field.

How to Insert a STYLEREF Field

Method 1: To Create a Field Using the Menus:
  1. Position the insertion point in the document where you want to insert the text to be entered.
  2. On the Insert menu, click Field.
  3. In the Categories list box, select "Links and References."
  4. In the Field Names list, select "StyleRef."
  5. The STYLEREF field will be displayed in the Field Codes text box below the Categories list box. Click in the text box to the right of the word STYLEREF and type the style name of the text you want to be displayed as the field result. For example, type:
    STYLEREF "Heading 1"
    NOTE: You must enclose the text in quotation marks.
  6. If a field switch is desired, select the Options button in the Insert Field dialog box. Select the field switch, and click the Add To Field button. Click OK.
  7. In the Insert Field box, click OK.
You will then be returned to the document.

To view the field code you just inserted, press {ALT}+F9.

Method 2: To Create a Field Using Keystrokes:
  1. Position the insertion point in the document where you want to insert the text.
  2. Press {CTRL}+F9.

    Field code brackets, {}, will appear in the document.
  3. Type the following inside the filed code brackets, where <stylename> is the name of the style applied to the text that you to be displayed:
    STYLEREF "<stylename>"
    NOTE: You must enclose the text in quotation marks.

EXAMPLES

Case 1--Using STYLEREF Fields in a Dictionary/Glossary

Use the STYLEREF field when creating a glossary to show the first and lastglossary words on each page--the same format you'll find in a dictionary.
   If the field codes resemble the following      {STYLEREF "Heading 2"}--{STYLEREF "Heading 2" \l}   the result of the field codes will be:      Apple - Baseball (where Apple and Baseball have been formatted with                        Heading 2 style)				

Case 2--Chapter Title to Appear in the Header

Use this format to insert the current chapter name as part of the header orfooter.
   If the field code resembles the following      {STYLEREF "Heading 1"}   the result of the field in the header will be:      File Management    (where File Management was the title of the                          chapter formatted with Heading 1 style)				

Effective Use of the STYLEREF field

To use the STYLEREF field effectively, you need to understand how Worddetermines which paragraph is the nearest one. That determination dependson where the STYLEREF field is and on whether the /l (the letter L) switchis being used.
   If STYLEREF   is here            Word will search here   -----------------------------------------------------------------------   Document Text      From the field code to the beginning of the document                      and then from the field code to the end of the                      document.   Footnotes,         From the reference mark in the document to the   Annotations,       beginning of the document, and then from the   and Endnotes       reference mark to the end of the document.   Headers and        From the beginning of the current page to the end of   Footers            that page, and then from the end of the previous page                      to the beginning of the document, and then from the                      beginning of the following page to the end of the                      document.                      If the \l switch is used, Word searches from the                      end of the current page to the beginning of the                      document, and then from the beginning of the                      following page to the end of the document.				
REFERENCES
For more information about the STYLEREF field, click the Index tab inMicrosoft Word 7.0 Help, type the following text
STYLEREF
and then double-click the selected text to go to the "Field codes: StyleReffield" topic.

In Microsoft Word 6.x, click the Search menu in Help and type
STYLEREF
and then double-click the selected text to go to the "Field codes: StyleReffield" topic.
Properties

Article ID: 141994 - Last Review: 12/04/2015 12:50:27 - Revision: 1.1

Microsoft Word 6.0 Standard Edition, Microsoft Word 6.0a, Microsoft Word 6.0c, Microsoft Word 6.0 for Macintosh, Microsoft Word 6.01 for Macintosh, Microsoft Word 6.01 for Macintosh, Microsoft Word 6.0 Standard Edition, Microsoft Word 95 Standard Edition, Microsoft Word 95a

  • kbnosurvey kbarchive kbfield kbhowto KB141994
Feedback