Using Fields Intelligently

Behind many of Word's most powerful features sits a peculiar document element called a field. Word fields are placeholders whose contents change dynamically; they typically work in the background, invisibly, displaying the correct data onscreen and in print, based on information within the current document, in other documents, or from external sources. For example, if you put a {Date} field in your document, it displays the current date each time you open the document.

Word supports more than 70 different fields. Use them when you want to accomplish tasks such as these:

  • Show the current day in a document ({date}, {time}), or the time the document was last printed ({printdate}).

  • Construct a paragraph numbering scheme ({seq}, {AutoNum}, {AutoNumLgl} ) more complex than those available in the dialog box that appears when you choose Format, Bullets and Numbering. A similar technique ({ref}, {styleref}) allows you to set up "Figure x-y" figure numbering captions that incorporate the chapter number.

  • Set up a "hot" button ({macrobutton}) or picture that runs a macro when clicked.

→ To run a macro based on a click inside a document, see ""Hot" Linking to Macros".

  • Refer to the contents of bookmarked text. For example, you can place a bookmark on a chapter title and refer to that title throughout your document by using the {Ref} field. If the title changes, all the references change, too.

→ For details on all the nuances of using bookmarks, see "Using Bookmarks".

  • Refer to the first or last occurrence of a particular style on a page. Use this type of field ({stylref}) in the header for a phone book, for example, listing the first and last entries ("Able, George to Alphonso, Chris") on each page.

  • Insert information about a document into the document itself ({info})—total number of pages, filename, author, file size, number of words, date when the document was last saved, and so on.

  • Perform calculations, comparisons, and even elementary arithmetic. For example, the {Page} field produces the number of the current page, whereas a {{Page}+1} field results in the number of the next page.

There's even a field that converts a postal ZIP Code to a USPS bar code!

Fields also drive such key built-in Word capabilities as tables of contents, figures, tables, equations, indexes, and mail merges. Although Word uses layers of wizards and dialog boxes to shield you from the field codes used to implement those features, sometimes the only way to tweak the feature—to limit a table of contents to a part of the document covered by a specific bookmark, for example—is by working with the field code itself.

Note

Fields are an enormous topic. In this book, you'll learn some of the more useful fields—ones that will increase your productivity—today. If you need a detailed fields reference, see Special Edition Using Microsoft Word 2002 (published by Que).


Caution

Many fields do not translate well into HTML-formatted files. If you need to use a field on a Web page, make sure you test it with all the commonly used browsers to ensure that it works properly.


Showing and Hiding Field Codes

Word allows you to flip-flop between seeing the field codes themselves and field code results—for example, between seeing

{Date @ "d-MMM-yyyy"}

and

001 001 1-JAN-2003
002 002 

To show field codes, choose Tools, Options; choose the View tab; and then check the Field Codes box. To return to showing field code results, clear that same Field Codes box.

Tip from

If you're going to do much serious work with field codes, you might want to add the Field Codes button to the Standard or Formatting toolbar or memorize the View Field Codes keyboard shortcut, Alt+F9. Either one toggles between showing field codes and showing their results.


→ For detailed instructions, see "Customizing Toolbars".

Field Code Syntax

Field codes can take on many different forms, but generally they look like this, with the field name and required or optional parameters enclosed in curly braces:

{Author * mergeformat}

In this case, the field {Author} has one parameter, called a formatting switch. The formatting switch, if present, controls the way the field result is formatted inside the document. Switches are discussed extensively in the "Formatting Field Results," section later in this chapter.

Note

In this book, you'll always see field codes as they appear onscreen, surrounded by curly braces—something like this:

{Seq Figures * mergeformat}

Of course, you can't type curly braces into a document and get a field code. There are only three ways to insert field marks (braces): Choose Insert, Field; use one of the built-in Word functions that produces a field code; or press Ctrl+F9.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.170.65