Microsoft KB Archive/141994

= WD: How to Use the STYLEREF Field in Microsoft Word =

Article ID: 141994

Article Last Modified on 8/17/2005

-

APPLIES TO


 * 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

-



This article was previously published under Q141994





SUMMARY
This article describes how to use the STYLEREF field. The STYLEREF field can be used to create a dictionary-style entries at the top of each page or to place the chapter title in the heading. This field is useful when you want 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 add information to a document, especially in the header or footer, automatically.

The STYLEREF field consists of the field, the name of the style assigned to the text to be returned as the result of the field, and field switches.

{STYLEREF "StyleName"}

{STYLEREF "StyleName" }

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 nearest paragraph formatted with the style specified in the STYLEREF field. Word will 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 examples in the "Examples" section of this article illustrate the possible uses of the STYLEREF field.

How to Insert a STYLEREF Field
Method 1: To Create a Field Using the Menus:  Position the insertion point in the document where you want to insert the text to be entered. On the Insert menu, click Field. In the Categories list box, select "Links and References." In the Field Names list, select "StyleRef." 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. 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.</li> In the Insert Field box, click OK.</li></ol>

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: <ol> Position the insertion point in the document where you want to insert the text.</li> Press {CTRL}+F9.

Field code brackets, {}, will appear in the document.</li> Type the following inside the filed code brackets, where is the name of the style applied to the text that you to be displayed:

STYLEREF " "

NOTE: You must enclose the text in quotation marks.</li></ol>

Case 1--Using STYLEREF Fields in a Dictionary/Glossary
Use the STYLEREF field when creating a glossary to show the first and last glossary words on each page--the same format you'll find in a dictionary. <pre class="fixed_text">  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 or footer. <pre class="fixed_text">  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 Word determines which paragraph is the nearest one. That determination depends on where the STYLEREF field is and on whether the /l (the letter L) switch is being used. <pre class="fixed_text">  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.

<div class="references_section">