A Closer Look at Field Instructions

Earlier in this chapter, you learned about field instructions: information that can be included with a field to adjust the way it behaves and the way it displays data in your document. You also learned about two of the most common types of field instructions: arguments and switches. Now you'll discover the power of two more kinds of field instructions:

  • Bookmarks enable your fields to work with blocks of text stored anywhere in your current document or even in another document.

  • Expressions enable you to build formulas into your field codes and have Word automatically update calculations just as a spreadsheet can.

Creating Fields That Can Work with Blocks of Text

In Chapter 22, "Using Footnotes, Bookmarks, and Cross-References," you learned that bookmarks are markers you can place anywhere in a document to identify a location or text you've selected. You can add a bookmark to some fields, thereby telling Word to go to that location or to use the bookmarked text for some purpose.

For example, the following { REF } field tells Word to insert text about Jones that you've bookmarked elsewhere in the document:

{ REF jones }


Bookmark names can be only one word, so you don't have to insert quotation marks when you insert a bookmark name in a field.

Or what if you don't want the bookmarked text to appear, but you want a cross-reference to the page number where the bookmarked text can be found? Use { PAGEREF }:

{ PAGEREF jones }


You can build this type of field using Insert, Cross-Reference, and then create an AutoText entry to quickly reuse it.

If you use the Field dialog box to select a field that uses a bookmark, a Bookmark Name scroll box appears, displaying a list of the bookmarks in your current document. Choose a bookmark. If necessary, you can continue to edit your field. When you're finished, click OK to insert the field in your document.

You can also insert bookmark names manually; in fact, this is your only option if you are using { INCLUDETEXT } to insert text bookmarked in another document.

Expressions: Creating Fields That Can Calculate

Expressions are field instructions designed to calculate?and to automatically update calculations when necessary?just as a spreadsheet program would.

The most basic Word expressions start with the = symbol. For example, if you enter the field

{ =24-8 }

Word displays the value 16.

Of course, this is a trivial example of what Word expressions can do. The real benefit of expressions is that you can base them on other information in your document?and when that information changes, the expression updates its results automatically. For instance, the field code

{ =joesales - bobsales }

tells Word to look for a bookmark named bobsales, which already contains a value, and subtract it from another bookmark named joesales, which also contains a value.

You can use the { IF } field to tell Word to display one kind of information if it finds one mathematical result, and different information otherwise. { IF } follows this syntax:

{ IF Expression1 Operator Expression2 TrueText FalseText }

In other words, you compare one value with another, and take one action if the resulting statement is true, another if it is false.

Consider the joesales/bobsales example. After you create the { =joesales - bobsales } field, you can bookmark it and name it joevbob. Now, you can build a field that pats Joe on the back if he outsells Bob. If not, it gently exhorts him to do better:

[View full width]
{ IF joevbob >0 "Congratulations, Joe, you're salesperson of the month!" "FYI, you're #2 graphics/ccc.gif this month." }


If you're working within a table, you can also use cell names (A1, A2, and so on) in place of bookmarks, so a table can perform many of the tasks of a spreadsheet.


If you want to reference one or more cells in another table, first select that table and bookmark it. Next, include the bookmark name in your formula alongside the cell reference. For instance, to include a reference to cell A4 in a table you've bookmarked as Table5, enter

(Table5 A4)

as in the following formula:

=0.6*(Table5 A4)

    Part I: Word Basics: Get Productive Fast
    Part II: Building Slicker Documents Faster
    Part III: The Visual Word: Making Documents Look Great
    Part IV: Industrial-Strength Document Production Techniques
    Part VI: The Corporate Word