Using { Fields } in Microsoft Word

by Charles Kyle Kenyon, Esq.

Last updated Wednesday, November 15, 2023.

There are no promises that this chapter is of the same quality and depth as the other chapters of this guide. That is because it was written by a single author not working with Microsoft and not subject to peer review. You will not find this chapter on the Microsoft site. Comments are welcome.

You may want at least skim the bookmarks and cross-reference portions of Complex Legal Documents before tackling this chapter. (Cross-references are one type of field.)

What You Will Learn

After completing this lesson, you will be able to:
bulletSee field codes and hide them
bulletUse Function and ShortCut keys to manipulate fields.
bulletFind fields in a document using Find.
bulletType a field from the keyboard and have it work.
bulletCopy a field from a newsgroup or email message or book and have it work.
bulletKnow and use the difference between the MERGEFORMAT and CHARFORMAT switches.
bulletInsert a date field.
bulletInsert calculated date fields.
bulletInsert a page number.
bulletUse the different Pagination fields
bulletInsert a calculation field.
bulletInsert a conditional (IF) field.
bulletInsert the name of the file (FILENAME) with the path or not.
bulletApply field switches to change how the field result appears on the page.
bulletInsert document information (properties) in your document body or headers and footers.
bulletUse a StyleRef field to copy information from the body to headers and footers.
bulletUse a StyleRef field instead of a Cross-Reference field.
bulletKnow that a StyleRef field will not work with hidden text.
bulletUse an ASK field, bookmarks and related cross-references.
bulletKnow where to find information on the Advance field.
bulletUse AutoText entries for insertion of fields
bulletUse a MacroButton field for a simple user prompt.
bulletUse a MacroButton field to run a macro that you record.
bulletUse a MacroButton field to make a templates menu document.
bulletCreate dictionary-style headers / footers describing page contents.
bulletConvert field codes to ordinary text to discuss using email or online forums
bulletUse multiple Sequence fields in a document for pleadings or sequentially numbered tickets
bulletUse vba (Visual Basic for Applications -- Macros) to insert a nested field
bulletInsert Bar Codes using a field

Other Chapters Related to Topics Covered in this Lesson

bulletNumbering - Sequence Fields
bulletComplex Documents (Tables of Contents, Authorities, Figures, Footnotes, Endnotes, Bookmarks, Cross-References)
bullet Sections - Page Numbering Fields

Additional Written (and Web) Resources

bullet Microsoft Support - Fields Reference - this is a great place to get a handle on fields or find a field. Organized by category and by field.
bulletMicrosoft Support - Fields Switches 
bulletMicrosoft Support - Insert, Edit, and View Fields in Word
bulletMicrosoft Support - Insert and Format Field Codes in Word 2010
bullet Formatting Word Fields with Switches by Graham Mayor, MVP
bullet Working with Fields and Forms (in Word 2013) by Faithe Wempen - no longer working so hidden
  bulletInserting Fields
  bulletSelecting the Right Field
  bulletUpdating and Editing Fields
  bulletFormatting Fields
bullet Fields Documentation (IMO better than Microsoft's) Better Solutions
bulletThe mailmerge.fields newsgroup on the Microsoft news server.
bulletMVP FAQ index Fields
bullet Fields Revealed by Sherry Kappel of Microsystems.
bullet How to hide a "Print" command button on a Form so that it doesn't print by Ibby 
bullet Repeating Data - entering once and having it show up elsewhere! by Greg Maxey, MVP
bullet Repeating Data Using Document Property Content Controls and Other Mapped Content Controls - Charles Kenyon
bullet Toggling Data Display Using MacroButton Fields by Greg Maxey, MVP
bulletMicrosoft MailMerge Resource Center - MS site
bullet How the Behavior of the Word Fields Changes After You Install the Word Update KB330079 - Applies to Word 2000 and later - documents FieldCalcSecurityLevel registry key
bulletCindy Meister's Articles from Office Developer (now OfficeVBA) Magazine:
bullet Word Fields Part I : Automate Word Documents With Minimum Code
bullet Word Fields Part II : Numbering Conundrums
bullet Word Fields Part III : (Advanced) Using Events to Push the Envelope (Includes Index Hyperlinks!)
bullet Mail Merge - Part I - Introduction and Data Integration
bullet Mail Merge - Part II - Employing Word's Field and Formatting Capabilities
bullet Mail Merge FAQ - MVP site
bullet How to Create A Mail Merge by Beth Melton, MVP and Dave Rado, MVP 
bullet Making Your MailMerge Intelligent using IF Fields by Dave Rado, MVP
bullet Turning Word into a Pseudo-Database Using Mail Merge Query Options by Dave Rado, MVP
bullet How to do a mail merge to the printer using VBA, without displaying the Print dialog by Ibby, MVP
bulletMicrosoft Webcast - MailMerge Basics - 45 minutes
bulletMicrosoft Webcast - Intermediate MailMerge - 45 minutes
bullet Insert Fields in Word on the Macintosh - Microsoft
bullet Word Fields by Greg Maxey
bullet Formatting Word Fields with Switches by Graham Mayor, MVP.
bullet Fields - Word Tips Allen Wyatt
bullet Working With Field Codes - Cindy Meister (part of her FAQ on Mail Merge) possibly included in her series of articles above - haven't analyzed
bullet Formatting Word Fields with Switches by Graham Mayor, MVP
bullet Tables of Contents, TOC and TC Fields by Suzanne Barnhill, MVP
bullet Word Fields and Relative Paths to External Files by Paul Edstein
bullet Microsoft Word Field Maths Tutorial by Paul Edstein - must reading for anyone trying to do anything complex with Word fields - backed up under third-party downloads on Graham Mayor's site.
bullet Field Code to String (and back) by Paul Edstein and Graham Mayor
bullet Page X of Y bugs and Workarounds
bullet How to Control Page Numbering in a Word Document by Bill Coan, MVP. Using Fields for Page Numbering - Much more Control - and see also...
bullet How to insert the filename and path on the last page of a document, such that it will be updated automatically if the filename or path changes by Bill Coan, MVP.
bullet Understanding Word Field Codes by Mike Lewis
bullet Keyboard shortcuts for manipulating fields and dates by Charles Kenyon
bullet Customizing Your Table of Contents with Switches by Suzanne S. Barnhill, MVP.
bulletThe {=} Field - Formula Field - Documentation on MS site 
bullet MacroButton Fields - not just for macros anymore! by Charles Kenyon
bullet Using MacroButton Fields by Graham Mayor, Jonathan West and Hak-lok NG
bullet Using {MacroButton} fields to insert information from the Outlook Address Book into documents such as letters by Graham Mayor, MVP
bullet Using Addin Fields by Hak-lok NG - this is virtually the only documentation available for these fields which accept / hold data which is not visible to the user (like document variables) - they can only be set or read using VBA
bullet StyleRef Field Tutorial - two-page download
bullet Functions and  Formulas you can use in a Word document
bullet Using Styles in Letterhead and in Headers and Footers by Charles Kenyon - StyleRef field
bullet Letterhead Textboxes and Styles Tutorial - two page download demonstrating StyleRef and Author fields, among other things
bullet IncludeText Field Tutorial - Ten-page, three-document tutorial with IncludeText links demonstrating switches, interaction of styles, and use of hidden Page field for continuous page numbering of separate documents. Also demonstrates the weird behavior of headers / footers in source document.
bulletMacro to replicate contents of a CheckBox formfield in place of { REF } field - download the Checkboxes Tutorial
bullet Conditional Drop-Down Form Fields
bulletMacro to update all fields in a document, including those in headers and footers - or just all REF fields if you want - See also Greg Maxey's page on Field Macros listed below
bullet Useful StyleRef Field Tricks by Suzanne S. Barnhill, MVP
bullet Understanding the Advance Field by Allen Wyatt
bullet Field Macros - Greg Maxey's page on using vba to manipulate fields
bullet Formatting Mailmerge Fields - Office for Mere Mortals
bullet Relative Addressing of Paths in Fields (for outside files) - thread on Woody's watch on vba programming to achieve this
bulletChapter 16 of Microsoft Word 2010 In Depth by Faithe Wempen
bulletWord Fields - WordTips page of tips Ribbon Interface - Menu Interface - More than 100 articles
bullet Field Codes: Not Just for Geeks
bullet Field Code Reference - Word 2010 (Virtually all of the information here applies to earlier versions of Word as well.)
bullet Word Fields – Useful Keyboard Shortcuts – Word Macros and Tips by Lene Fredborg, MVP
bullet STYLEREF Fields and Language-specific Style Names by Lene Fredborg, MVP
bullet Updating Fields in Word – How it Works by Lene Fredborg, MVP
bullet How Cross-Reference Fields in Word Work by Lene Fredborg, MVP.
bullet Formatting Cross-References by Suzanne Barnhill, MVP
bullet Conditional Headers and Footers (Advanced) by Greg Maxey, MVP
bullet Some Fields are Updated While Others Are Not - Microsoft
bullet Articles on Fields by Allen Wyatt
bulletDate Fields - Calculated - Advanced
bulletChris Woodman: http://www.chriswoodman.co.uk/Delayed%20Dates.htm
bulletHow do I insert a date? Why does it (not) change when I open the document?
bulletCalculated Dates: http://www.addbalance.com/word/datefields2.htm (also below)
bullet Calculated Dates - a Word document by Paul Edstein (macropod) - examples of very complex calculated date fields that you can modify to suit your purposes - alternative download site on Graham Mayor's site - my go-to resource!
bullet Calculating Dates with Fields by Allen Wyatt
bulletHow to Add Pop-Up Lists to Any Word Document So You Can Click Your Way Through Changes in Seconds (or how to use the AutoTextList field) by Bill Coan, MVP.
bulletCheckboxes Tutorial - Add-In - Examines different kinds of checkboxes, allows putting active checkboxes in a document / template that is not protected for forms.
bulletSample Forms
bulletPublic Defender Payment Voucher - Summary cover sheet with five time sheets. Extensive use of tables, cross-references, calculated fields. (zip format)
bulletPublic Defender Transcript Request Form (based on printed form - wild layout of fields using tables, some use of bookmarks, use of exit macros to control tab order. (zip format)
bulletSample Templates using fields
bulletASK fields sample form Two-Page tutorial uses ASK field in conjunction with bookmarks and REF fields. Latest version also has FILLIN fields for comparison.
bulletUserForm sample Tutorial with open code. UserForm, bookmarks & cross-references
bulletGender toolbar Add-In - use of calculated fields based on document property. Fields are inserted using AutoText from a menu.
bulletCheckBox Global Template - Active Checkbox fields that work without a protected form. Open VBA code.
bulletLetterhead System - uses bookmarks and date fields
bullet Letterhead Textboxes and Styles Tutorial - two-page template download that demonstrates use of 
bullettextboxes in headers and footers to reserve space for preprinted letterhead
bulletStyles that are based on each other and use the style for following paragraph feature
bulletUse of the StyleRef field to insert information from the body of a letter into the continuation page headers automatically
bulletInsertion of a date automatically that will not change when you open the document at a later date (but can be changed manually)
bulletSee How can I get a different header - footer on the second page in Microsoft Word? for more on how this tutorial works.
bullet Legal Toolbars - date fields stored as AutoText entries available on drop-down menu
bullet My document becomes empty but the file size is not changed What to do when your entire document becomes a field!
 
bullet

Word Help topics:

bullet

Dictionary-style headers

bullet

Fields

 

Click to return to table of contents page of Legal Users' Guide to Microsoft Word.Click to go to Microsoft Word new users frequently asked questions site in a new browser window.
(this guide table of contents) ------- (MS Word New Users FAQ)

 

"A field in a Word document is simply a placeholder that contains the instructions for what should go here rather than the text itself."
 
John McGhie 
"Word's Numbering Explained"

Fields Overview

You will find fields to be one of your basic tools in preparing document templates that will automatically update themselves to reflect information you want to be in the document. Combining them with AutoText will give you a handy toolbox that you can use in all of your documents. 

This chapter is not a total review of fields, but rather a look at the ones that people working in a legal environment (or similar workplace) have found useful.

How to type fields in Word

The { } field delimiters can not be typed using the braces characters on the keyboard. They are special Word characters that have to be inserted as a pair using Ctrl+F9, or Insert => Field... or Insert => Cross Reference... or some other special field insertion command. If you are using Ctrl+F9 you can either press Ctrl+F9 first and then type your field or type the field code first, select it, and press Ctrl+F9. Once you are done with the field, press F9 to update the field and display the result.

I call these delimiters { } "braces" in this and other pages. Microsoft calls them brackets, but to me brackets have right angles and look like [ ] so I'll go on calling delimiters braces.

Some computers have hijacked the Function keys in their BIOS. These computers should have a Fn shift key on their keyboards. So, instead of Ctrl+F9, you would press Fn+Ctrl+F9 (or edit the BIOS so that function keys act as described in documentation for programs).

Keys on the Macintosh are similar but different. (Cmd+F9 or Fn+Cmd+F9) See Keyboard Shortcuts that control fields below.

How to toggle the Display of Field Codes in Word

Sometimes (rarely) you want to see the field codes rather than the text generated by a field. You can use the keyboard shortcut Shift+F9 to display the coding of a simple field. This does not necessarily show everything. There is a corresponding command in the right-click menu to Toggle Field Code display. Again this only applies to the field selected and does not necessarily show the entire field.

To see everything you have to change the option to display field codes rather than field results. This can be set in your Word Options or Preferences, but the simple way is to use the keyboard shortcut of Alt+F9. This switches all fields in the Word session to display or hide field codes.

Note, this is a Word option toggle and remains set for all Word documents and future Word sessions until toggled back.

Again, for complex fields you will want to use Alt+F9 rather than Shift+F9. This is easily demonstrated using a complex merge form field from one of my legal templates.

Field revealed by Shift+F9

Field revealed by Alt+F9

As you can see, Shift+F9 may not show you everything. When you have field codes displayed in a document using Alt+F9, they will print rather than the field code results. This is great for debugging, but not what you usually want. You can also choose to print them as a print option even if they are not displayed.

The XE (Index Entry), TC (Table of Contents Entry) and TA (Table of Authorities Entry) fields are exceptions. Those fields are displayed when Hidden text is displayed and are not affected  one way or the other by the toggling of Field Code Display. Complex Documents - Microsoft Word Intermediate User's Guide - Table of Contents - Table of Authorities - Cross-References

Some computers have hijacked the Function keys in their BIOS. These computers should have a Fn shift key on their keyboards. So, instead of Alt+F9, you would press Fn+Alt+F9 (or edit the BIOS so that function keys act as described in documentation for programs).

Keys on the Macintosh are similar but different. (Opt+F9 or Fn+Opt+F9) See Keyboard Shortcuts that control fields below.

You can do this in your Word options / preferences rather than using the keyboard shortcuts.

Word Options dialog for Field Code display preferences

 

How to copy a field from a newsgroup or email message into Word:

If you are using a typed field display from a newsgroup or email message first make sure that the field isn't broken up by any line breaks or paragraph breaks. (Lines that are wrapped automatically by Word are fine but turn on Show All to make sure there are no special characters at the end of the line.) Select the text inside a matched pair of braces and press Ctrl+F9. Word will insert its field delimiters around the text. Delete the typed braces.

For instance, with the field:

{ = { REF "Number1" } * { REF "Number2" } }

first select

REF "Number1"

and press Ctrl+F9, then select

REF "Number2"

and press Ctrl+F9, then delete all of the typed braces and select everything from the = sign to the end of the second field and press Ctrl+F9 again.

Then press F9 to update the field and display the result.

If you press Alt+F9 (view field codes) you'll see something that looks very much like what you started with except the field delimiters look like bold braces and the field will probably be shaded. Press Alt+F9 again to go back to viewing the field result.

You can also use the macro found on Graham Mayor's site to convert fields to/from plain text.

For more on fields, follow the links on the Word Web Resources Page. For a table of shortcut keys dealing with fields, see below.

Using the Insert Field... dialog box to insert fields

The Insert Field Dialog box is virtually unchanged since Word 97. You get to it in Word 97-2003 using Insert > Field, and in Word 2007 and later using Insert (tab) > Quick Parts > Field.

Insert Field dialog (CreateDate)

Insert Field Dialog (Field Codes > Field Options)

The screenshots above are for the Insert Field dialog box using the CreateDate field. The first shows the dialog box as it first appears. The second shows what you see after you click on the Field Codes button (bottom left) and then on the Options button.

Note that the default is to check the box for "Preserve formatting during updates." This sounds like and seldom is a good idea. Most experienced users of fields uncheck this box. It inserts a MERGEFORMAT switch. Much more useful, usually is the CHARFORMAT switch. Word MVP Graham Mayor posted code (a macro) to uncheck this by default and to ask about the CHARFORMAT switch if it is checked. I incorporated this macro in one of my office's Add-Ins several years ago and have never regretted it. Here is more info on the difference between these two.

Using the Insert Field dialog box is much easier than writing fields but the most complex fields cannot be constructed using this dialog. A prime example is an IF field that compares different values that are also fields. Here is an example of such a complex nested field:

{ QUOTE "{ SET " Delay" "14" }
{
  SET "DaysInMonth" { IF { CreateDate \@ "MM" } <> 2
{
  = ROUND(30.575*
{ CreateDate \@ "MM" },0)-
ROUND(30.575*
{ = { CreateDate \@ "MM" } -1 },0) }
{
  IF {  = MOD( { CreateDate \@"yy" } , 4 ) } > 0 "28" "29" } } }
{
SET "NextMonth" {  IF {  CreateDate \@ "MM" } = 12 "1/97" 
"
{ = {  CreateDate \@ "MM" } + 1 }/97 } }
{
  IF {   = REF "Delay" } + { CreateDate \@ "dd" } } <= { REF"DaysInMonth" }
{
CreateDate \@ "MMMM { = REF "Delay" } + { CreateDate \@ "dd" } }, yyyy"}{ QUOTE { NextMonth \@ "MMMM"
} 
{
 =
{ REF "Delay" } + { CreateDate \@ "dd" } - { REF"DaysInMonth" } }
{
IF { CreateDate \@ "MM" } <> 12 { CreateDate \@ "yyyy" }
{
CreateDate \@ "{ = 1 + { CreateDate \@ "yyyy" } \# "xxxx" }" } } } }" }

The colors in the sample field above represent my attempt to match field delimiters and show nesting of fields. I hope it helps. Those fields shown in green contain no nested fields but may contain references to bookmark values set by other fields. Line breaks have been added for clarity and should not be a part of the actual field. This is all part of a single QUOTE field.

The Difference Between MERGEFORMAT and CHARFORMAT

When writing fields I seldom use either switch, but when I use one, it is almost always the CHARFORMAT switch. Both keep the formatting when the field is updated.

\* MERGEFORMAT

Word inserts the MERGEFORMAT switch by default when you insert most fields. This switch keeps any manual formatting you apply to the field or part of the field. It is seldom what you want! If to a part of the field, it applies to the position in the field, not the word.  I.e., if you have a field result that is: "please respond immediately" and you Italicize "immediately" If it later changes to "please respond after your board meeting," "after" will be will be italicized because it is the third word in the field. If the result changes to "please give me a call after you've had a chance to study this" the word "me" will be Italicized. This switch has nothing to do with the formatting of the source material. Neither does the CHARFORMAT switch.

\* CHARFORMAT

The CHARFORMAT switch allows you to control the formatting of the entire field result. It sets the format to be the same as the first (non-space) character of the field code itself. To use it, you must be display the field code. Whatever direct formatting you apply to that first character will be used for the field result. I usually format the entire field name rather than just the first character, but this is not required.

{ REF myBookmark \* CharFormat }

MyBookmark = "Hello There!"

Field result: Hello There!

MVP Graham Mayor wrote a macro a while back that I use. It turns off the default insertion of MergeFormat and if you check the box to preserve formatting, it asks you if you want to use the CharFormat switch instead. I highly recommend it. You can download it from his page.

 

 

Field Categories (per Microsoft)

bulletDate and Time
bulletDocument Automation
bulletDocument Information
bulletEquations and Formulas [sic]
bulletIndex and Tables
bulletLinks and References
bulletNumbering
bulletUser Information

The DATE field and its variations.

The easy way (but probably wrong way for what you want) to put a date in your document is Insert => Date or Alt+Shift+D.

If you don't check "Update Automatically" it is the same as typing the date yourself. If you do check "Update Automatically" it will update when you print (if you have the setting under printer options as "Update Fields" which is the default). You can manually force an update by putting your insertion point in the date and pressing the [ F9] key.

If you want to put a date in a template that updates to the current date when a document is created based on the template, or want to change the format or do other things with the date field, you want to use Insert => Field => Date and Time instead. Using the options here, you can either pick a format or type your own characters (called a picture) for the format. The options for the type of date include:

bullet{ DATE } - The date you are looking at the document. Always today (although it may not show on screen as today until you update the field).
bullet{ CREATEDATE } - The date the document was created (or saved using Save As).
bullet{ PRINTDATE } - The date the document was last printed.
bullet{ SAVEDATE } - The date the document was last saved.

The above are the field codes that will be inserted for you using Insert => Field => Date and Time without using any options. A "\*MERGEFORMAT" switch is automatically inserted if you check "preserve field format" and means leave formatted the same way the field is formatted. Generally, you do not want to check this box or add this switch. If you want one of these formatting switches, you probably want "\*CHARFORMAT" instead.  This switch formats the field result however the first non-blank character within the field is formatted. As with all fields, you must let Word insert the field delimiter braces { }, you cannot simply type them. See the introductory material in this page.

If you choose options, they can include the following "pictures:"

 Picture

 Displayed Date

 \@MMMM d, yyyy

 August 1, 2000

 \@MMM dd, yyyy

 Aug 01, 2000

 \@MM/dd/yy

 08/01/00

\@dddd, MMMM d

 Tuesday, August 1

 \@ddd, MMM. d, yyyy

Tue., Aug. 1, 2000

 \@MM/dd/yy hh:mm:ss am/pm

 08/01/00 10:36:12 PM

example: { CREATEDATE \@ "MMM dd, yyyy" }

The word "picture" in the above table indicates a guide to Word on how you want your field to display and print. (Normally called a "mask" in other programming but Microsoft decided to call this a picture for its own reasons.) If you don't like the pictures you are offered, pick the one that is closest to what you want and then modify it in the Insert Field dialog box (or in the codes themselves using Toggle Field Codes). For more on "pictures" and formatting dates see: Fields Switches.

For information on calculated date fields and a toolbar button that creates such fields, see: http://www.addbalance.com/word/datefields2.htm

Remember that fields in headers and footers don't get updated quite as predictably. They work fine with CREATEDATE but can have the same problem as page numbers (see that topic) with DATE.

 

 

The Function and Shortcut Keys that manipulate fields

Windows Keys

What

Macintosh Keys
F9 Update/Refresh Selected Field F9
Shift+F9 Display/Hide Field Codes (selected field) * Shift+F9
Alt+F9 Display/Hide All Field Codes (all fields in document) ** Opt+F9
Ctrl+F9 Create Empty Field 
(Insert { }Braces)
Cmd+F9
Alt+Shift+F9 Run Macro (MacroButton Field Only) Opt+Shift+F9
Ctrl+Shift+F9
or
Ctrl+6
Unlink Selected Field (delete all field coding and replace with field result) - turn field into text Cmd+Shift+F9
or
Cmd+6
F11 Go to (Select) Next Field F11
Shift+F11 Go to (Select) Previous Field Shift+F11
Ctrl+F11
or
Ctrl+3
Lock Field (prevent manual or automatic update) Cmd+F11
or
Cmd+3
Ctrl+Shift+F11
or
Ctrl+4
Unlock Field (allow updating) Cmd+Shift+F11
or
Cmd+4
Alt+I, F Insert Field (Dialog Box
(Alt+I followed by F)
Opt+I,F
Alt+Shift+D Insert Date Field *** Ctrl+Shift+D
Alt+Shift+T Insert Time Field *** Ctrl+Shift+T
Alt+Shift+P Insert Page Field Ctrl+Shift+P
Ctrl+Alt+L Insert ListNum Field Cmd+Shift+Opt+L
Alt+Shift+O Insert TC Field Ctrl+Shift+O ?

* It is possible to have fields inside of fields (nested fields). If this is the case, the Shift+F9 Toggle will not show all the field codes, only the outermost layer. To see all the field codes, use Alt+F9 instead. For more about this, look at Display of Field Codes above.

** Alt+F9 is the same as checking / unchecking Field Codes in Tools => Options => View. Unlike a field code toggled using Shift+F9, if you update a field while all field codes are being displayed, the new field result will still be hidden and you will see the field codes.

*** Probably not the field you want to insert, though. This gives the continuously updating field. See Datefields in Microsoft Word.

If the function keys are not working, chances are good it has to do with your Computer (or another program) intercepting them. Try adding the Fn shift key to the mix. See Hijacked Function Keys.

See also MVP Lene Fredborg's article: Word Fields – Useful Keyboard Shortcuts – Word Macros and Tips

Advance Field

The Advance Field is an old field. It is intended to position text exactly on a page, sometimes out of order. The preceding link is to Microsoft's documentation. Note that the \y switch apparently does not work in Word 2013. That switch is for vertical placement relative to the page.

Finding Fields in a Document Using the Find Command

When field results are displayed (the normal condition) the Word Find command cannot find them. It will find their results. To be able to find fields, you must toggle the display of fields to show the field codes. This can be done using the Alt+F9 keyboard shortcut.

Once field codes are displayed, you can use the Find command. Search for ^d and you will find fields. There is no similar function for Replace.

 

Bookmarks and Cross References (from Complex Legal Documents)

Inserting Bookmarks

We have all used bookmarks at one time or another. We've dog-eared pages and even used sticky notes to mark where we have left off in a book. Word does the same thing in long documents. If you have bookmarked a paragraph or heading in your document, the next time you open the document you can use Goto to move to your bookmarked location.

This is especially handy when you find that there are parts of your document that are constantly being updated. You can use bookmarks to jump in and out of those problem spots quickly.

Note CK Note: Bookmarks are also one of the best ways to have text inserted in one place reflected elsewhere in the document -- or even in another document! You do this by insertion of a cross-reference to the text of the bookmark. Cindy Meister refers to this as the second mode of bookmarks -- not just holding a place in a document but holding content in a document. Another good way in versions of Word 2007 and later is by use of Document Property Content Controls and Other Mapped Content Controls
Practice: Insert a Bookmark
  1. Select any text on the page.
  2. From the Insert menu, choose Bookmark (or press CTRL+SHIFT+F5).

The Bookmark dialog for inserting bookmarks

(In Word 2007 and later the control to insert a Bookmark is on the Insert Tab of the Ribbon. The Ctrl+Shift+F5 shortcut continues to work.)

  1. Create a name for your bookmark in the Bookmark name field (you cannot start a Bookmark name with a number, and Word won't allow spaces within the name).
  2. Click Add. (Notice that Word has added this new bookmark to the bookmark list.)
  3. Click Close.
Navigating With Bookmarks

Now that you have marked your document with bookmarks, let's go over the easy ways to move throughout your document using them.

Practice: Find your Bookmarks
  1. Press F5 on your keyboard. The Find and Replace dialog box appears, with the Go To tab activated. In the Go to what list, find Bookmark.
  2. One of your bookmarks will fill the Enter bookmark name field. If this is not the bookmark you are looking for, click the drop-down arrow and select the bookmark that you want to find. Click Go To, and Word will take you to the bookmarked location.

    The Find and Replace dialog with the Go To tab selected, to find a bookmark

  3. You can go to the next bookmark by pressing F5 again and selecting the new bookmark name and clicking Go To.
Warning CK Warning: Bookmarks are fragile creatures and easily deleted when you are editing bookmarked text! For instance, if you follow the directions above to go to a bookmark, you will have the bookmark (as well as the bookmarked text) selected. If you make changes without adjusting this, you will delete the bookmark and any references to that bookmark (see below) will be invalid. 

When you are working with bookmarked text, keep your view options set to view bookmarks and your Undo key handy! When I am working with bookmarked text and want to preserve the bookmark, I will put my insertion point (cursor) inside of the bookmarked text - just after the first letter of that text. I will then insert the changes that I want to make and delete the surplus text by hand using the delete or backspace keys. 

This fragility exists in all versions of Word to date (2013).

For more on bookmarks see: Word Bookmarks by Cindy Meister

 

Working with Cross-references

To refer the reader to another part of the document, you can insert a cross-reference. See How Cross-Reference Fields in Word Work by Lene Fredborg, MVP.

Here is a video in the legal context: How to cross-reference and Interrogatory

Note CK Note: Cross-reference fields can refer to bookmarked text. Further, instead of simply providing a link or a page number for referenced text, cross-reference fields can reproduce that text. This one of Word's ways of repeating variable text in a document. In Word 2007 and later another great way is with Document Property Content Controls and Other Mapped Content Controls.

With both the links in cross-references and in those from hyperlinks, in Windows the keyboard shortcut Alt+Left Arrow should return you to your previous location after you have used the link.

Practice: Insert a Cross-reference
  1. Create a new document and type the following:
    Introduction
    Overview
    Unsolicited Proposals
    Solicited Proposals
    General
    The Proposal
  1. Click anywhere within the first line, Introduction.
  2. Click the Style drop-down arrow and apply Heading 1 (or use Ctrl+Alt+1 shortcut).
  3. Select Overview, and apply Heading 2 (or use Ctrl+Alt+2 shortcut).
  4. Select Unsolicited Proposals, Solicited Proposals and General. Apply Heading 3 (or use Ctrl+Alt+3 shortcut).
  5. Select The Proposal and apply Heading 2 style, and after deselecting the text press Enter twice.
  6. Your cursor is where the cross-reference is to be inserted.
  7. Type something to the effect of, "For more information, see".
  8. From the Insert menu (tab), choose Cross-reference.
     

  - 
   -

 

  1. In the Reference type drop-down list, select what reference type is appropriate for your cross-reference, for this example use Heading as the reference type. You can also use a numbered item, bookmark, footnotes, endnotes, equations, figures or tables.

In the Cross-reference dialog box, you also have a choice of how you want the reference to look. You could reference the heading text as shown above, or Page #, Heading #, Heading # (no context), Heading # (full context), and above/below.

  1. Select Unsolicited Proposals and click Insert. The dialog box remains open for any other cross-references that you may want to add. If you do not want to add more cross-references, just click Cancel.
  2. As you can see, your cross-reference has been marked. If you click "Unsolicited Proposals," Word takes you to the heading.

Jumping to a cross reference in a document

  1. If you inserted as a link, you can use that link to go from the cross-reference you inserted to the source. As with a hyperlink, after you have used such a link you can use the keyboard shortcut of Alt+Left Arrow to return to your original position.

Updating Cross-references

If you have changed your text that is a cross-referenced passage in your document and the cross-reference has not updated, you need to update the field. You can alternate-click on the field code and select Update Field, or select the field code and press F9. This updates the field to reflect recent changes.

Note CK Note: If the material in a cross-reference displays a field in the original text, you may want to include the following "switch" in your cross-reference field code: \!  This is the "lock result" switch and prevents a field like { DATE } in your original bookmarked text from updating in your cross-reference when you update the cross-reference field, unless it has been updated at the source. (Complex, I know, but you usually will want to use this switch.)

Further, you can use a macro to update all Cross-Reference fields at once. The following macro will update all cross-reference documents in the main body of a document.

Sub UpdateAllRef()
' Based on code at http://www.gmayor.com/installing_macro.htm
' Update all Ref fields in a document, even if in headers/footers
Dim oStory As Range
Dim oField As Field
	'
For Each oStory In ActiveDocument.StoryRanges
For Each oField In oStory.Fields
If oField.Type = wdFieldRef Then oField.Update
Next oField
	'
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
For Each oField In oStory.Fields
If oField.Type = wdFieldRef Then oField.Update
Next oField
Wend
End If
	'
Next oStory
	'
Set oStory = Nothing
Set oField = Nothing
End Sub

For instructions on how to use this macro, see Graham Mayor's Installing Macros page.

Although Cross-Reference fields are hyperlinks, they do not look like hyperlinks. You can change this. See Formatting Cross-References by Suzanne Barnhill, MVP.

Word's built-in heading styles are designed to use with cross-references in ways other styles are not. See Why use Word's built-in heading styles? by Shauna Kelly.

See also Word MVP Lene Fredborg's page on Troubleshooting Cross-References

 

 

ASK Fields

Ask fields are very close to WordPerfect's prompt fields. When you create a new document that contains an ASK field, you are asked a question (written by the person who created the template) and given a dialog box in which you can answer the question. Your answer is then inserted into a zero-width bookmark and can be accessed by using a {REF} field anywhere in the document (or even in another document with an INCLUDETEXT field.)

You can test the value of the bookmark using an IF Field and put various text into a MailMerge depending on the value given. If use in a MailMerge, the question in the ASK field will be asked for each record and the IF field evaluated for that response for that record.

As with most fields, if you type "ASK field" into Word help, you will get the Microsoft reference page on the field. The ASK field predates Word 95 and is very stable.

This is still in its infancy. See my download page for examples of ASK fields. As with all fields, you must let Word insert the field delimiter braces { }, you cannot simply type them. See the introductory material in this page. Many fields do not update automatically or when the underlying condition changes without a little help, either a manual update using the F9 key or a macro. You usually do not want an ASK field to update.

Pagination Fields

Word has four fields that work for page numbers. These are {PAGE}, {NUMPAGES}, {SECTIONPAGES}, and {DOCPROPERTY PAGES}. These can be used in Calculation and IF fields and are normally used in headers and footers. They are classified as Document Information fields.

PAGE field

The simplest way to insert a PAGE field is Alt+Shift+P. They can be inserted through Word's interface as well. These methods insert a { PAGE } field in the Page Number Character Style. If you type the word "Page" without quotation marks, select it, and press Ctrl+F9, then F9, you will create the same field not in any particular style.

In its simplest form this will display the page number, numbered from the beginning of the document. You can format any of the page number to display in Roman numerals (upper- or lower-case), Arabic numerals, or as text. More on that later. You can restart the page numbering anywhere you want; doing so will insert a new Section if you are not already at the start of a new Section.

The PAGE field updates instantly upon a change in pagination of the document.

NUMPAGES field

The NUMPAGES field reports the total number of pages in the document. Unlike the PAGE field, it is not possible to restart the numbering of the NUMPAGES field. The NUMPAGES field, like the PAGE field updates upon any change in pagination.

SECTION field

The SECTION field reports the number of the Section in which it is located. If placed in a header or footer it shows the section in which the page starts. (There can be more than one section on a page.)

SECTIONPAGES field (there is no SECTIONPAGE field)

The SECTIONPAGES field reports the total number of pages in a Word Section. A document must have at least one Section and can have many. It is often used to number Appendices in a document. There is no SECTIONPAGE field that would correspond to the PAGE field. See Page Numbering on Greg Maxey's site for a workaround that allows the user to have both the Section pages numbers and of the Document page numbers in the same spot. This field also updates instantly. You can vote on UserVoice for Microsoft to add such a SECTIONPAGE field.

DOCPROPERTY PAGES field

Technically, this is a use of the DOCPROPERTY field with the Pages argument. In most cases it will report the same number as the NUMPAGES field but it has been used as a workaround for instances when the NUMPAGES field does not update properly and if there is a Cover Page in a Word 2010-2013(365) document, this will include the Cover Page in the numbering while the NUMPAGES field will not. When there is a Cover Page the number reported by NUMPAGES and the document property may be different.

The NUMPAGES field will update more frequently than the DOCPROPERTY field. Its updating in virtually instant while the DOCPROPERTY field follows other rules.

Cover Page complexity

In Ribbon versions of Word, a Cover Page can be inserted in a document. In Word 2007 this will be counted in all of the pagination fields. In Word 2010 - 2019 it which will be counted as page number 0 in the PAGE field. It will not be counted by the NUMPAGES field in Word 2010 and 2016-2019 and will be counted in Word 2013. It will be counted in the DOCPROPERTY PAGES field and in the SECTIONPAGES field! See Cover Page Anomalies.

PAGEREF Field

This is not actually a pagination field but can be used in various ways including in calculation fields involving page numbering. It gives the page number on which a particular bookmark is found. Here is a link to the Microsoft page on this field.

Formatting Page Numbers

The PAGE field can be formatted using the Format Page Number dialog. All of the pagination fields can be formatted using field switches.

In Word 97-2003 you access the dialog to format page number dialog under Insert > Page Numbers... and then clicking on the button to Format Page Numbers.

Word 2003 Insert Page Numbers Dialog

In Ribbon versions (2007+) you click on Format Page Numbers under the Insert Tab > Page Number.

Word 2010 Page Number Format

In any version you get a dialog to format page numbers that lets your restart page numbering or change the way the numbers are displayed. The dialog from Word 2010 is shown below.

This dialog lets you select a format as well as include a Chapter number based on a style to start a chapter. When doing chapter pagination, one normally begins the chapter with a new Section and restarts the pagination at the beginning of the section. You can only restart pagination with a section break. Although this dialog gives a number of formatting options, at this point, I will discuss field switches instead.

You can use any of the number format switches used with fields by inserting your field through Insert > Field (Word 97-2003) or Insert > Quick Parts > Field (Word 2007-2013). That brings up a dialog like the following:

You can use any of the numeric field switches with your pagination fields. For the DocProperty Pages field you would need to edit the field code manually; the dialog will not insert the switches. If you toggle the Field Code display (Alt+F9) to look at codes and then toggle back, you will see (for the number 15) as follows:

 Field Code

 Field Result

{ PAGE } 15
{ PAGE \*roman } xv
{ PAGE \*Roman } XV
{ PAGE \*Arabic } 15
{ NUMPAGES \*Roman } XV
{ SECTIONPAGES \*OrdText } fifteenth
{ SECTIONPAGES \*OrdText \*FirstCap } Fifteenth
{ SECTIONPAGES \*CardText } fifteen
{ NUMPAGES \*CardText \*FirstCap } Fifteen
{ DOCPROPERTY PAGES \*CardText \*FirstCap } Fifteen
{ = { NUMPAGES } - 1  } 14
{ PAGE \*alphabetic } o (letter between n and p)
{ PAGE \*Alphabetic } O (letter between N and P)

These switches work in any field that has numeric information. More about using calculation fields and page fields: How to control the page numbering in a Word document.

Switches are ignored in any Table of Contents / Table of Figures. Those fields pay attention to the format set in the page number format dialog.

In Ribbon versions of Word Page number fields are also in Building Blocks under the Insert>Page Number button. You can find an example of additional building blocks structured as header/footer building blocks for the Page X of Y structure on my Downloads Page. As with all fields, you must let Word insert the field delimiter braces { }, you cannot simply type them. See the introductory material in this page.

MacroButton Field Tips and Tricks - not just for macros

The MacroButton field is a field developed in early versions of Word (pre-Windows). The name comes from the ability to trigger a macro. It was early used to insert dummy text for typing and can still serve that function well, without any macros. It continues to work, well, in Word 2019.

bullet Syntax and Behavior
bulletMacroButton Field Prompts for Entry of Text
bullet MacroButton Fields to run a Macro
bulletMacroButton Field where Macro Responds to Contents of the Field
bullet Making MacroButton Fields Respond to a Single Click
bullet Using MacroButtons function as Hyperlinks in documents protected for filling in forms
bullet Different Behavior for Images in MacroButton Fields in .doc and .docx Format Documents with Workarounds for .docx Format
bullet Comparison of MacroButton Fields and Content Controls
bullet Additional References on MacroButton Fields

MacroButton Fields - Syntax and Behavior

Syntax 

{ MacroButton MacroName DisplayText }

MacroButton - the field command

MacroName - name of macro being called - or "NoMacro"

DisplayText - text that acts as the "button" for the macro and is displayed in your document. Note that there are no quotation marks used in this field. DisplayText can be any text you want but will not wrap to a new line. There are limits on length. Instead of the DisplayText you can insert an inline picture or icon to act as a visual button for your macro. See below, though for images. The text in a MacroButton field prompt cannot be longer than a single line between the left and right indents for the paragraph. You can shrink the font size of the prompt text to fit more words on that single line.

Behavior

Clicking on a MacroButton field will select the field. Double-clicking on one will activate a macro if there is a macro designated. You can change this behavior to make the macro activate on a single click as well.

MacroButton Fields as Prompts

You can use the first behavior (selecting the field) to make simple click-and-type prompts. If you look at many of the templates that come from Microsoft with Word, you will find places that say something like "[Click here and type]." If you click at that spot, the whole prompt is selected and anything you type replaces it. Often, this is exactly what you want for a simple prompt. What you are seeing is a simple implementation of the "MacroButton" field. This use of the macrobutton field is the forerunner of Content Controls.

To insert a MacroButton field like this in your document type it then make it a field.

As is the case with all fields, you cannot simply type the field braces { }. You either have to use Word's Insert => Field or press Ctrl+F9 and type the field contents. To get: { MacroButton NoMacro DisplayText } you could simply type "MacroButton NoMacro DisplayText" and select it. Then press the Ctrl+F9 key combination to make it a field. Pressing F9 will update it to the field display of DisplayText. You must create or edit the field manually to get colors or other formatting in your prompt text that will disappear when the user actually uses it and types.

Inserting a MacroButton field like this in your document using the Field insertion dialog is a bit more involved:

(Word 97-2003) Insert => Field ... 

(Word 2007-2019) Insert => Quick Parts => Field ...

Where it says Field: type "MacroButton NoMacro prompt." The "MacroButton" is the name of the field. "NoMacro" is the name used by the field for the macro to be called - in this special case, none. The "prompt" is whatever prompt text you want. This can be "[Click here and type]" or the text that will usually be just fine but which the user might want to change. "NoMacro" is used as a convention to indicate that there is no macro being used. Note that if there was an available macro with the name "nomacro" that macro would be run by this field. Any name that does not indicate an available macro will give the same result, that is, the entire field will be selected when clicked on (as always happens with a MacroButton) but since no macro can be found, the result is selected text. If you want to format your prompt text, you need to do that by revealing the field code and editing. To me, typing the field and then using Ctrl+F9 to insert the braces is much easier.

As is the case with other fields, the F11 key will take you to the next field, selecting that field. When you use macrobutton fields as prompts, you may want to put an instruction in your documents to use F11 to go to the next field. I do this putting the instruction in blue or red text and a different font in a textbox formatted to float in front of text. The textbox is formatted to have no lines and no fill. The text in the textbox is formatted as hidden so it should not print. I have this textbox as an AutoText entry in my developer's template so that I can insert it easily when I prepare a new template.

Below is an example of how a Macrobutton Prompt appears in a document. (Screenshot) The field code for this prompt is:

{ MacroButton NoMacro This is a macrobutton prompt! When you click on it, all is selected. }

The first paragraph shows the prompt as displayed on the page. The second shows the prompt after it has been clicked on before typing; the third shows that the prompt colors do not show up in the text after the user types.

You can download a free Add-In that gives you a dialog box below to add a MacroButton prompt to your document where you want with a choice of colors for the prompt text.

Picture of custom dialog box from Add-In. Click to go to download page.

Dialog box from Add-In

MacroButton Fields to Run Macros

Instead of simply being a prompt for typing, this MacroButton field will run a macro if double-clicked. (This can be altered to a single click using VBA.) Instead of NoMacro, simply type the name of the macro. When inserting the field, you can click on the Options button and you will be given a list of available macros (possibly quite a long list) from which to select.

Where it says "Macros defined in active document" a more accurate caption would be "Macros available to active document." This list also includes all of Word's built-in commands, many of which are not found on the menus.

Note that the MacroButton field is selected when it is clicked or double-clicked. You may want to have your macro collapse the selection at some point so that your MacroButton field won't be inadvertently deleted. The language for this is:

Selection.Collapse 
'Unselects the current selection and places 
'insertion point at beginning of selection.

Note also that a macro button prompt will print as ordinary text. (It is the field result). To avoid it being printed, you may want to put it in a no-border text box formatted as hidden text (Format => Font). Because of this, it is often easier to use a custom toolbar with a button on that toolbar. The toolbar will not print.

MacroButton Fields can be used in Protected Forms and will be active even in a protected portion of the document. They are often used in such forms as a replacement for hyperlinks (since regular hyperlinks are inactive in the protected portion of a form).

A simple example of macrobuttons can be found in the CheckBox template. This template/tutorial combines the powers of macros, autotext, and the macrobutton field.

MacroButton Fields where the Macro responds to the contents of the field (uses them as an argument or variable for the macro)

It is possible to use one macro that responds to the contents of the field to change what the macro does. Doing this with Private or AddIn fields incorporated in MacroButton fields is discussed in the MacroButtons page on the MVP FAQ site. The same technique can be used with just the display text of the MacroButton field.

The macro is:

Sub TestMacro2()
Dim MyString As String
    'Ignore first 24 characters of the macrobutton field -
    '   the words 'MacroButton TestMacro2', and the spaces
    MyString = Mid$(Selection.Fields(1).Code, 24)
    MsgBox MyString
End Sub

The field is:

{ MacroButton TestMacro2 [Click Here] }

This can be used to construct a list of templates in the Workgroup Templates folder as macrobuttons. When you double-click (or single-click as shown below) on the macrobutton, the macro creates a new document based on the named template. A single macro decides which template to open based on the template listed in the macrobutton field.

That is, the following fields both call the same macro:

{ Macrobutton TemplateListLoad Releases\Release - blank} (Displays: Releases\Release-Blank)

{ Macrobutton TemplateListLoad Log} (Displays: Log)

The macro uses the display information to decide which template to use. The macro is:

Sub TemplateListLoad()
'   Based on ideas from http://wordmvp.com/FAQs/TblsFldsFms/UsingMacroButton.htm
'   Macro written by Charles Kyle Kenyon
'   24 October 2002
'
    Dim sTemplateName As String
    Dim sTemplatesPath As String
    '
    '   Get workgroup templates path
    '
    sTemplatesPath = Options.DefaultFilePath(wdWorkgroupTemplatesPath) & "\"
    '
    '   Parse template name from Macrobutton field.
    '   (The selection is the entire field.)
    On Error GoTo ErrorHandler
    sTemplateName = Mid$(Selection.Fields(1).Code, 31) & ".dot"
    '   Use to create a new document based on the template
    Documents.Add Template:=sTemplatesPath & sTemplateName
    Selection.Collapse
    Exit Sub
    '
End Sub

Making MacroButtons respond to a single click

To me, double-clicking on a button is counter-intuitive. To make a macrobutton respond to a single click to run a macro the following VBA code has to be active:

Options.ButtonFieldClicks = 1

This has to be run before the user tries to click on the button. It can be in an AutoOpen or AutoNew macro in the template which contains the macrobutton or in an AutoExec macro in a global template. (Explaining these gets beyond the scope of this article; see Template Basics for more.)

Using MacroButtons to function as hyperlinks in protected forms.

In a document that has been "protected" as a form in Word, hyperlink fields don't work, but macrobutton fields do work. You can use a macrobutton for a hyperlink to an external document or web page (and even format it to look like a hyperlink) in a protected document. It is more work than merely inserting a hyperlink, though. (You can also use a macrobutton to link to an internal bookmark with reservations, see end of this section.)

  1. With your document not protected for forms, record a macro that opens the document to which you want to link. Save the macro in your document (not in Normal.dot) when you record it.
  2. Use the Macro Editor (Alt+F11) to edit your macro. At the end of the macro (just before "End Sub") add the following line.
      Selection.Collapse
  3. Where you want your hyperlink Press Ctrl+F9 to insert your field codes and type "MacroButton MyMacro displaytext." where "MyMacro" is the name of your macro and "displaytext" is what you want the hyperlink to show in your document. (See Syntax above)
  4. Press F9 to update your field. It should show your displaytext.
  5. Select your field and press Ctrl+Shift+S to get into the styles drop-down.
  6. Type "hyperlink" for the style name and press enter.

When you protect your document your pseudo-hyperlink should work fine. Remember to set the ButtonFieldClicks to 1. Also, the mouse pointer will not change to a little hand when passing over your pseudo-hyperlink - but we can't have everything, can we?

If you would like some pre-written code for your hyperlink macrobutton, you can download HyperJmp.zip from the Visual Basic MVP site.

For alternative coding, take a look at Using Hyperlinks in Protected Forms on the MVP site. They show how to use a single macro for all your hyperlinks in the document.

When the target of the link is within the protected form it doesn't work quite so well. It will jump to the field addressed by your bookmark if your bookmark is for a formfield, otherwise to the field following your bookmark. If there is no field following your non-field bookmark, it jumps to the first field in the document. Note that fields inserted with the Forms toolbar automatically have a bookmark assigned. (You can change that bookmark in the field's properties.) Thanks to Marcy T. for bringing this problem to my attention.

For more on protected forms, follow the links in my web resources page, especially those to Dian Chapman's excellent series of articles.

Example of MacroButton Field Use in Multiple Ways - The Microsoft Fax Transmittal Template from Word 97

Note the checked box by "For Review." Here is the same template after toggling display of Field Codes (Alt+F9). The prompts for user input are MacroButton fields not associated with any macro. A dummy name of "NoMacro" is inserted but the purpose of the field is to display the prompt. The checkboxes in the form are MacroButton fields, not Form Checkboxes or Content Controls! Both of these use the property of MacroButton fields to select the entire field when clicked on. The display text for the checkbox fields is the unchecked or checked box.

If there were an active macro named NoMacro (or nomacro) these MacroButton fields would call that macro!

The name of the macro called by the (unchecked) Urgent checkbox is "CheckIt." The one called by the (checked) For Review checkbox is "UncheckIt." Look again at the form with the field codes not showing. All you see is the display text - the checked and unchecked boxes.

See Checkbox Add-In for samples.

Different behavior with images for text in .doc vs .docx formatted documents

An image does not work well as a prompt in document (templates) formatted as .docx or .docm (.dotx or .dotm). These are the document and template formats for the Ribbon versions of Word (2007+). See this post on the Microsoft Answers forum. The image is selected, not the field. If the image is deleted by the user and the user types, that typing becomes the prompt for the field. Clicking or double-clicking on the field will not run a macro.

If the same document is saved in .doc or .dot format, the macrobutton field will act as specified. The screenshot below is from a document in .docx format when the MacroButton Field has been clicked on.

Here is a screen shot of the same thing, except the same document has been saved in .doc format:

In the .doc format, clicking on the image selects the field containing the image (and a double-click will run an associated macro). If the user types anything, the image is deleted, the field is deleted, leaving only the typing. When in .docx format, the image is selected in the field. No macro is run. If the image is deleted by the user and the user types, what the user types becomes the new MacroButton field prompt! If there is no image, or if the user clicks on a text prompt included with the image, the field is selected, including the image, and replaced by typing.

Here is another sample using a smaller image, in .docx format:

3. shows the field structure with the button image following the text.

1. shows what it looks like when the image is clicked on. Note the image moves in front of the text even though formatted to be inline with text. If there is a macro, it will not run in this condition.

2. Shows what it looks like when the space after the text is clicked on or the field is entered using the F11 (next field) function key. When this is done, if there is a macro, it will run.

What happens in these instances when text is typed?

In Word 2007 and later when you click on the image, any text typed is added to the MacroButton Field prompt text. If the field itself is selected or you click in the area following the image, the field is replaced by typing. In this second instance, if there is a macro, it is run first.

If the same fields are saved in a .doc (Word 97-2003) format, the field simply acts as a macrobutton field.

See Greg Maxey's page on Toggle objects for some ways to get Word to respond to images in macrobutton fields. One method is with spaces, another is with the IncludePicture field inserting the image. The second suggestion comes from Doug Robbins. An example using the IncludePicture field:

{ Macrobutton NoMacro { INCLUDEPICTURE "https://addbalance.com/word/images/PillcrowFlying.gif" } }

Using that construction, the image is selected with the macrobutton (and replaced by typing).

MacroButton Field Prompts compared to Content Controls

Macrobutton prompts and text content controls can have a similar appearance in a document. Here is a screenshot showing plain text Content Controls and a MacroButton field prompt. Both have the placeholder text formatted using the PlaceHolderText style.

bullet

Both select the entire contents when you click in them. When not selected, they can be indistinguishable to the user.

bullet

The color of placeholder text can be edited when you create them and can be something that is very different from the color of the text that will be typed.

bullet

Unless formatted to delete the content control when  edited, the content control will remain with edited text. The macrobutton field will be replaced by typing.

bullet

MacroButton field prompts will work in versions of Word that do not work with Content Controls as well as those that do. This includes Mac versions.

MacroButton Fields and the Table of Contents

If you have a MacroButton Field that is in text that shows up in a Table of Contents, it will be formatted as a Hyperlink in the Table of Contents and the Macrobutton Field will be an active field in the TOC. (This is not true of a hyperlink field.)

Additional references on MacroButton fields

bullet How to create a template that makes it easy for users to “fill in the blanks”, without doing any programming
bullet Enable a user to double-click text in a document to change its value
bullet Run a macro when a user double-clicks a button in the document
bullet MacroButton field reference on MS site
bullet Checkbox AddIn - a tutorial on the use of MacroButton fields together with AutoText and Macros to insert checkboxes into non-protected documents. 
bullet Using Macrobutton fields to insert information into documents and templates by Graham Mayor, MVP
bullet Using MacroButton Fields by Graham Mayor, Jonathan West and Hak-lok NG
bullet Using {MacroButton} fields to insert information from the Outlook Address Book into documents such as letters by Graham Mayor, MVP
bullet Instant Envelopes Using the MacroButton Field and VBA by Dian Chapman, MVP
bullet Using MacroButton Fields to insert information into documents and templates by Graham Mayor, MVP - includes details on the Checkit method used in early Word templates

Click to return to table of contents page of Legal Users' Guide to Microsoft Word.Click to go to Microsoft Word new users frequently asked questions site in a new browser window.
(this guide table of contents) ----- (MS Word New Users FAQ)

Search Usersguide to Microsoft Word using Google

 

 

 

The GoToButton Field

The GoToButton field acts very much like the MacroButton field and has a similar structure. I'm not sure why it is an improvement over a Hyperlink.

{ GotoButton MyBookmark Text }

A double-click will take the user to the bookmark location. If the bookmark contains something, it will be selected.

The GoToButton field responds to the options.ButtonFieldClicks setting discussed earlier in MacroButton fields.

Other references on this field seem to say it mimics pressing Ctrl+G to go to a place in the document. That is true only if the place is identified by a bookmark. Here is a screenshot of the Insert Field dialog.

GoTo Button Field Microsoft Word Help

The Ctrl+G GoTo Command allows going to headings and page numbers, among other options.

Using the STYLEREF Field

  1. Insert => (Quick Parts =>) Field... => Links and References (left window) => STYLEREF (bottom of right window)
  2. Pick or type the style name (right or center window)
  3. If the style has automatic numbering, the number will not appear without a switch, only the text.
  4. Choose options or leave blank (If blank, you get the text formatted in the style)
    1. Search from bottom of page to top (\l switch)
    2. Insert paragraph number (without text - \n switch) 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.
    3. Insert postition of paragraph (above/below - without text -\p) This is of little use in headers and footers.
    4. Insert paragraph number in relative context (without text - \r switch) Inserts the entire paragraph number of the bookmarked paragraph in relative context — or relative to the paragraph numbering scheme — without trailing periods.
    5. Suppress all non-delimiter characters (used with displaying numbers - \t switch) 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.
    6. Insert paragraph number in full context (\w switch) Used with one of the other numbering switches. 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.

    When placed in a header or footer, the StyleRef field updates instantly with any change in the source text. When placed in the body of a document, it updates the way other fields in the body update. Generally a print preview will update fields but not always.

    See also: Useful StyleRef tricks by Suzanne Barnhill, MVP.
    Here is the Microsoft Reference page for the StyleRef field.
    See also: STYLEREF Fields and Language-specific Style Names by Lene Fredborg, MVP

Switches and the checkboxes

The checkboxes in the Insert Field dialog correspond to the "switches" for that field.

TroubleShooting the STYLEREF Field

  1. StyleRef field gives an Error Message

"Error! No text of specified style in document."

This is pretty self-explanatory. The specified style must be in use somewhere in the document.

"Error! Not a valid bookmark self-reference."

This one is a bit more rare. It is telling you that the field, itself, is in the specified style. It is trying to reference itself.

  1. StyleRef does not show anthing - blank!

This indicates that the StyleRef field is referring you to blank text. In the case of a paragraph style, an empty paragraph formatted in the style. In the case of a character style, a space formatted, by itself, in the style.

  1. StyleRef field is showing text from previous pages or following pages and you do not want this.

This means that there is nothing in the specified style on the current page. If you would prefer that it show nothing, create a blank in the specified style. (See #2 above.) See also Suppressing a StyleRef Field by Suzanne Barnhill, MVP.

 

Using the STYLEREF Field and Styles in the header/footer instead of multiple sections with different Headers / Footers

Do you want your headers or footers to reflect the content of the page, or change from Chapter to Chapter?

You can use the StyleRef field with Word's built-in Heading Styles to change the content of the Header / Footer to reflect local document contents. Thus the Header/Footer can change to reflect headings and other content.

Using the STYLEREF Field to create dictionary-style headers/footers

Are you trying to get dictionary style fields (Krofta - Lamb) listing the first and last entry on your page?

If that is what you are trying for, the following will work:
Put your last name field (or whatever it is you are trying to capture) in a particular character style in your primary merge document.
The character style does not need to look any different from surrounding text but it can look different.

In the header/footer use two STYLEREF fields with an optional switch on the last one to tell it to search from the bottom of the page instead of the top. STYLEREF fields probably don't show up in the mailmerge toolbar.

Insert => (Quick Parts =>) Field... => Links and References (left window) => STYLEREF (bottom of right window) => Options (button)

{ STYLEREF \l }

If the StyleRef field gives you nothing but does not give an error, that means that the specified use of the style has no text.

Look in help for "dictionary-style headers."

You can name the character style anything you want and it should be based on your default character font with no changes. You are using the style as a tag rather than as a way of formatting. Remember, this new style is a character style rather than a paragraph style.

This is especially useful when you have something on the first page of a document which, if changed, should be reflected in continuation page headers or footers. Examples: the addressee name, the subject, the date. Useful StyleRef Field Tricks - Suzanne S. Barnhill, MVP

If you are doing this in a mail-merge, you may have to insert the header after you do the merge. Try inserting it before you do the merge, if that doesn't work, then try after. (I haven't tried this with a mail merge but it should work. After you get results, please share them by letting me know so I can update this.

Using the STYLEREF Field and Styles instead of Bookmarks and REF fields

Do you want something entered in one place in your document reflected elsewhere?

{ StyleRef "MyStyle" } instead of { Ref "MyBookmark" }

If your have a single word or a phrase in a document marked in the character style "MyStyle" that word or phrase will be reflected in this field's results, instantly. This updates in headers and footers as well as in the body when the marked text is changed. It is much more robust than bookmarks which are easily deleted by accident. See Letterhead Textboxes and Styles Tutorial - two page download demonstrating StyleRef and Author fields, among other things.

Either a character style or a paragraph style will work with the StyleRef field. The style does not have to change any formatting - it can just serve as a marker for the field. In the tutorial the styles used do have formatting functions as well -- primarily the paragraph spacing and the designation of the following style.

Note: it has been observed that if there is a bookmark with the same name as the reference style it can cause problems. See this forum thread.

Making a StyleRef field only appear if there is text in the style - getting rid of the Error message!

If you use a StyleRef field and there is no text in that style anywhere in the document, you will get an error message. That probably is not what you want. You can use a conditional (IF) field to screen the error message.

The following nested field displays nothing unless there is something in the named style. If something is present in that style, it gives you the text set in the style as well as extra comment text in the field.

{ IF {STYLEREF "stylename"} <> "Error!*" "{STYLEREF "stylename" } extra comment text" }

If you do not need the extra comment text, do not put it in the field. Note that this structure cannot be created using Word dialogs; you must edit the field code itself in the document. As with all fields, you must let Word insert the field delimiter braces { }, you cannot simply type them. See the introductory material in this page.

This field coding came from responses to a Word Answers forum question. Another: Hiding Errors when StyleRef does not find the Style

Thank you to Paul Edstein, Doug Robbins, and Suzanne Barnhill for this field coding!

Useful StyleRef tricks by Suzanne Barnhill, MVP

StyleRef Fields and Language-Specific Style Names - Lene Fredborg, MVP

More on StyleRef Fields - Lene Fredborg, MVP

StyleRef Field documentation BetterSolutions.com

StyleRef Field documentation Microsoft

Note, if the StyleRef field finds text that has been formatted as hidden, it will display blank. It will not search for the next displayed text.

Formula (Calculation) Fields - Conditional Fields

A formula field is one that does some kind of calculation and shows you the result. It starts with an equals sign:

{ = 1 + 3 - 1 }

will show a result of 3. Calculations are performed in much the same way as in algebraic expressions. 

Field Result
{ = 1 + 3 - 1 }

3

{ = 1 + 3 - 1 * 4 } 0
{ = (1 + 3 - 1) * 4 } 12

See the help files for more information on the rules for what gets calculated first.

When used in online (protected) forms, make sure that the source of the calculation has the property checked to "calculate on exit." Here is an example which takes the Number from one formfield, multiplied by the price from another. Formfields can be given names which Word treats as bookmarks.

{ = Number * Price }

Formula fields can be nested and can use results of other fields as parts. They can be used as a part of conditional fields.

As with most other fields, if you type "Formula Field" in Word Help, you will get the Microsoft Reference page on the = field. Most fields do not update automatically. If the conditions change after insertion of the field, the field may have to be updated manually.

Conditional Fields - The IF field

The structure of an {IF} field is: {IF expression1 operator expression2 "truetext" "falsetext"}. Expression1 operator expression2 means a statement that will be either True or False. Expression1 and expression 2 can be fields or text or a number. Operator is the test condition and should come back as true or false.

Operator Description
= Equal to
<> Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to

{IF 1=1 "One does equal one!" "This one doesn't equal that one!"} Trivial? How about: {IF {REF "Gender"} = "Male" "He" "She"}. (Download the Gender Toolbar template to see how this works in real documents.) An example of the same thing using a mergefield would be: {IF { Mergefield Gender } = "Male" "He" "She"} You may have noticed that we have one field inside of another field here! Yes, fields can use other fields for parts of their structure.

An If field can be used to display/hide a table or pull in the contents of a completely different document depending on the results of the condition.

Note that the tests for text in the IF field are case-sensitive. y is not the same as Y; Male is not the same as male.

As with all fields, you must let Word insert the field delimiter braces { }, you cannot simply type them. See the introductory material in this page.

As with most other fields, if you type "IF Field" in Word Help, you will get the Microsoft Reference page on the field. If the condition changes after insertion of the field, the field may have to be updated manually.

If Field Practice: A footer entry that only appears on the last page?

How would you put the document name and path in the footer of your document to appear only on the last page of the document?

You can insert an automatic page number anywhere in a document (especially in a header or footer) by pressing Alt+Shift+P. This gives you a {PAGE} field that displays as the correct number. Doing this is probably preferable to using the Menu command (Word 2003 and earlier) which inserts a page number in a frame. Frames are not in the main document and it makes editing difficult. Likewise, you can use the Insert Page Number choices under the Insert tab in Word 2007 and later but that overwrites existing headers and footers!

The first thought is "I have put a condition on this. I need a conditional Field! - an {IF} field!  In this case, there are two page numbering fields that can be used and compared. 

{PAGE} = {NUMPAGES}

The first field is the field to display the current page number. The second is to display the total number of pages in the document. Normally, these are used in "Page {PAGE} of {NUMPAGES}." The only time this statement will be true is if this is the last page in the document. We have our expression.

We want the document's name with its path. The field for a document's name can be found in the Document Information category: the { FILENAME } field. An optional switch for this field is "\p" so what we want is the field { FILENAME \p }. We can add something else to our {IF} field to print on other pages if we want; how about the Page X of Y noted above? So, our conditional field looks like:

{ IF { PAGE } = { NUMPAGES } "{ FILENAME \p }" "Page { PAGE } of { NUMPAGES }" } 

On the last page, this will print the full document name. In a four-page document, on page three, it will print "Page 3 of 4."

Question for the curious:

What will the following field print if placed in a footer? When?

{IF {PAGE} < {NUMPAGES} "Page {PAGE} of {NUMPAGES}" "{FILENAME \p}" }

Click here for answer. Further exercise: What fields would you use if you only wanted something to appear in the header or footer of the third page of the document, the next-to last page of the document? See How to Control the Page Numbering in a Document. See that page as well if you have numbering restart at some point in your document.

 

Nested {IF} Fields

One {IF} can be used inside of another one to give logical branches and twists.

{IF {PAGE} = 1 "This is the first page." "{IF {PAGE} < {NUMPAGES} "Page {PAGE} of {NUMPAGES}" "{FILENAME \p}" }" }

This is called "nesting." The nested IF field is used if the first expression is false. If you think this is complex, wait until we tackle date fields! Here is my article on the Microsoft website on how to create these: Nested IF Fields - A method to create them.

When used in online (protected) forms, make sure that the source of the calculation has the property checked to "calculate on exit."

bullet IF Field Reference on Microsoft Office site - Word 97-2003
bullet IF Field Reference on Microsoft Office site - Word 2007-2013
bullet Examples of IF Fields - Microsoft Office site - Word 97-2013
bulletGender toolbar Add-In - makes extensive use of IF fields to test for gender document property

 

Date Fields using IF

Here is an example of a calculated date field written in response to the request: 

I need to create a fiscal year field in Word 97 that accomplishes in Word what the following statement accomplished in English:

If today's month and day are less than or equal to June 30, display the current year, else display current year + 1.

{ IF { DATE \@ "MM" } < 07 { DATE \@ "yyyy" } { = { DATE \@ "yyyy" }+1 \# "0000" } }

If today were January 31, 2001, the following expression using that field for the year would display: "June 30, 2001" where the year is the field and the rest of the date is regular typed text. If today were July 1, 2001, the same expression would display as  "June 30, 2002." This might be used in a phrase such as "the end of this fiscal year, June 30, 2001."

This uses the test IF field together with date fields and an equation field to display the result if the result is a different year. The formats for the dates are set using date pictures. However, if the result is a different (calculated) year, then you need to use a number picture. In this case, I started out with a two-digit year and was using the picture 00. With a four-digit year, the picture becomes irrelevant.

The field shown above handles the year part of the date. It would have to be combined with an additional DATE field to get the month and day. Note that the field above might work better with a CREATEDATE field instead of the DATE field. With the CREATEDATE field and the additional field for the month and day, we get:

{ CREATEDATE \@ "MMMM d"}, { IF { CREATEDATE \@ "MM" } < 07 { CREATEDATE \@ "yyyy" } { = { CREATEDATE \@ "yyyy" }+1 \# "0000" } }

 

Here's a head-spinner! Dizzy! This little head-spinner emoticon borrowed from Woody's Word Lounge. Click to go there. The following is an example of a field that gives you the date two weeks from the day a document is created, in regular written English format:

Creation date: July 9, 2001 - desired field result = July 23, 2001
Creation date: July 23, 2001 - desired field result = August 6, 2001
Creation date: December 20, 2001 - desired field result = January 3, 2002
Creation date: February 27, 2003 - desired field result = March 12, 2003
Creation date: February 27, 2004 - desired field date result = March 11, 2004

{ QUOTE "{ SET " Delay" "14" }
{
  SET "DaysInMonth" { IF { CreateDate \@ "MM" } <> 2
{
  = ROUND(30.575*
{ CreateDate \@ "MM" },0)-
ROUND(30.575*
{ = { CreateDate \@ "MM" } -1 },0) }
{
  IF {  = MOD( { CreateDate \@"yy" } , 4 ) } > 0 "28" "29" } } }
{
SET "NextMonth" {  IF {  CreateDate \@ "MM" } = 12 "1/97" 
"
{ = {  CreateDate \@ "MM" } + 1 }/97 } }
{
  IF {   = {  REF "Delay" } + { CreateDate \@ "dd" } } <= { REF"DaysInMonth" }
{
CreateDate \@ "MMMM { = {  REF "Delay" } + { CreateDate \@ "dd" } }, yyyy"}{ QUOTE { NextMonth \@ "MMMM"
} 
{
 =
{ REF "Delay" } + { CreateDate \@ "dd" } - { REF"DaysInMonth" } }
{
IF { CreateDate \@ "MM" } <> 12 { CreateDate \@ "yyyy" }
{
CreateDate \@ "{ = 1 + { CreateDate \@ "yyyy" } \# "xxxx" }" } } } }" }

The colors in the sample field above represent my attempt to match field delimiters and show nesting of fields. I hope it helps. Those fields shown in green contain no nested fields but may contain references to bookmark values set by other fields. Line breaks have been added for clarity and should not be a part of the actual field.

You can download a document containing the above field to play with if you like. I wouldn't advise trying to reproduce it by hand! This particular field is a tweaked result of a very nice Add-In by Chris Woodman which seems to be no longer available online. For more on date calculations see Calculated Dates which includes links to other pages on date field calculations as well as some discussion of VBA methods of handling date calculations.

You can look here for an example of using an IF Field for mailmerge to make part of the mailmerge conditional.

 The FILENAME field - insert the name of your document

The FILENAME field will insert the name of your document in the document. This is used most frequently in document footers. Note that the document must be saved to make this field operational. Whether the name appears as  "MyFile" or "MyFile.docx" depends on whether you have filename extensions displayed in your operating system.

You can add the \p switch to this field { FILENAME \p } to give the full name, the filename with its path. This field was used in the IF field example shown above to give the filename only on the last page of a document.

Using Fields with AutoText

The AutoText field can be used in templates to call AutoText (or other Building Blocks) into a document from a template or Global Template. This is useful for things like local address/and phone number, the name of a person or an email when a template is to be used company-wide but needs to be tailored for an individual or a local office. To do this, you would use the AutoText field (or an AutoTextList field) to insert that local information. See Automated Boilerplate Using Microsoft Word.

Fields can be very complex and laborious to construct. One of the most efficient ways to insert complex fields into your documents and templates is by saving the field, itself, as an AutoText entry. An example of a template that does this is the Gender Toolbar template that can be downloaded from my downloads page.  It has fairly complex IF fields that can be inserted from a menu in a custom toolbar.

If there are multiple template sources of AutoText entries, Word follows its hierarchy for templates in choosing which one to insert. I do not know which building block will be chosen if their are different building blocks having the same name (but in different galleries) in the same template. As with all fields, you must let Word insert the field delimiter braces { }, you cannot simply type them. See the introductory material in this page.

There is an AutoTextList field which can be used to give a dropdown list of AutoText entries that were stored with certain styles. This is an old and underutilized field. See AutoTextList field - How to add pop-up lists to any Word document, so you can click your way through changes in seconds by MVP Bill Coan and AutoTextList in the Modern Age by Greg Maxey.

 

Formatting Field results (what shows on screen and prints)

How your field looks and prints depends on (1) the formatting applied to the paragraph (direct or styles), (2) the formatting applied to the characters (direct or styles), and (3) any field formatting switches. In this section, we'll look at the switches that you might want to use. Remember, display your field codes by pressing Alt+F9. See also: Formatting Word Fields with Switches by Graham Mayor, MVP.

Those applied by default:

 

Capitalization (case) switches:

Switch

Result

\* caps Capitalize Each Word
\* firstcap Capitalize the first word only
\* lower lowercase text
\* upper UPPERCASE TEXT

Dates: reviewed above

Numbers:

Instruction switches (as distinguished from picture switches)

Switch

 

Result & Explanation

\ * cardtext Cardinal number Converts numbers in the result to cardinal text form. To control case, add another format switch that specifies capitalization. For example, {= sum(A1:B2) \ * cardtext} gives a result such as "seven hundred ninety." The field {= sum(A1:B2) \ * cardtext \ * caps} gives a result such as "Seven Hundred Ninety." Can be used in a Page field to spell out page numbers. {PAGE \* cardtext \* caps} Can be used in a merge field to spell out a number. { Mergefield Age \*  cardtext }
\ * dollartext Check format Converts numbers in the result to cardinal text, inserts "and" at the decimal place, and displays the first two decimals (rounded) as arabic numerators over 100. For example, {=9.20 + 5.35 \ * dollartext} gives the result "Fourteen and 55/100."
\ * ordinal Ordinal number Converts numbers in the result to arabic ordinal form. For example, {DATE \ @ "d" \ * ordinal} gives a result such as "30th."
\ * ordtext Ordinal text Converts numbers in the result to ordinal text form. To control case, add another format switch that specifies capitalization. For example, {DATE \ @ "d" \ * ordtext \* caps} gives a result such as "Fourteenth." The field {DATE \ @ "d" \ * ordtext \ * upper} gives a result such as "FOURTEENTH."
\ * alphabetic   Converts the result to alphabetic characters. The result has the case of the first character of "alphabetic." For example, {SEQ appendix \ * Alphabetic} gives a result such as "B" instead of "2."
\ * Arabic (default) Converts numbers in the result to arabic cardinal form. For example, {PAGE \ * arabic} gives a result such as "31." When the setting in the Number Format setting in the Page Number Format dialog box (Header-Footer View, Page Numbers Format Button, View menu) is other than arabic, the "\ * arabic" switch overrides the dialog box setting.
\* hex hexidecimal Converts numbers in the result to hexidecimal numbers. For example, {QUOTE "458" \ * hex} gives the result "1CA."
\ * roman Roman numeral Converts numbers in the result to roman numerals. The result has the case of the first character of "roman." For example, {SEQ chapter \ * Roman} gives a result such as "XI." The field {SEQ chapter \ * roman} gives a result such as "xi." Useful in page numbering for front matter.
 Note, switches which convert numbers to text of some sort are responsive to the proofing language of the field. For instance:

"1" \* OrdText in English will give "first" but

"1" \* Ordtext in Spanish will give "primero."

Picture switches

Syntax

\ # "instructions"

Remarks

Specifies how to display the numeric result of a field. This switch is called a "picture" switch because you specify a pictorial representation for the field result. For example, the field {= SUM(ABOVE) \ # "$#,##0.00"} displays a currency result such as "$4,455.70" because of the "\ # "$#,##0.00"" Numeric Picture switch. If the result of a field is not a number, this switch has no effect.

Note

Quotation marks are not required around simple numeric pictures that do not include spaces (for example, {mayreturns \ # $#,##0.00}). For more complicated numeric pictures and those that include spaces, you must enclose the entire numeric picture in quotation marks (for example, {= mayreturns+junereturns \ # "$#,##0.00 'increase';$#,##0.00 'decrease'"}). When you add a Numeric Picture switch to a field using the Add To Field button in the Field Options dialog box (Field command, Insert menu), Word automatically encloses the numeric picture in quotation marks.

Use any combination of the following instructions to build your numeric picture.

 

Switch

 

Result & Explanation

\# "00.00" 0 (zero) Required digit placeholder. A zero in the numeric picture indicates that you want a digit to appear in that place in the result. If the result does not include a digit corresponding to a zero's position, a zero is displayed. For example, {= 4 + 5 \# "00.00"} displays the result "09.00."
\# "##.##" # (number sign) Optional digit placeholder. Number signs in the numeric picture indicate that you want a digit to appear in that place in the result only if the result calls for it. If the result does not include a digit corresponding to a number sign's position, a space is displayed. For example, {= 9 + 6 \# "$###"} displays the result "$ 15."
\# "x" x (round) Truncating digit placeholder. Drops any digits to the left of the placeholder, and rounds up when placed to the right of the decimal point. For example, the field {= 3/4 \# ".x"} uses a truncating digit placeholder to the right of the decimal point that rounds the result up to one decimal place. The calculation yields .75, which is rounded to .8 in the field result.
  decimal point Indicates where to place the decimal point. For example, {= SUM(ABOVE) \# "$###.00"} displays a result with two digits to the right of the decimal point. The character you use as a decimal point must match the decimal character in your system setting. Typically, this is a period (.) in the United States and a comma (,) for many other countries. Use the International option in Control Panel to set the decimal character for your system.
  thousands separator Separates series of three digits to display large numbers clearly. For example, {= NetProfit \# "$#,###,###"} displays a result such as "$2,456,800." The character must match the thousands separator character in your system setting. Typically, this is a comma (,) in the United States and a period (.) for many other countries. Use the International option in Control Panel to set the thousands separator character for your system.
\# "-" - (minus sign) Adds a minus sign if the result is negative, or a space if the result is positive or zero. For example, {= 10 - 90 \# "-##"} displays the result "-80."
\# "+" + (plus sign) Adds a plus sign if the result is positive, a minus sign (-) if the result is negative, or a space if the result is zero. For example, {= 100 - 90 \# "+##"} displays the result "+10."
  positive; negative Specifies different number formats for positive and negative results. For example, {= sales93 \# "$#,##0.00;-$#,##0.00"} displays a positive result for the bookmark "sales93" in regular character formatting-such as "$1,245.65"-and a negative result in bold character formatting with a minus sign-such as "-$ 345.56."
  positive; negative; zero Specifies different number formats for positive results, negative results, and a zero result. For example, {= sales93 \# "$#,##0.00;($ #,##0.00);$0"} displays a positive result for the bookmark "sales93" in a format such as "$1,245.65," a negative result in parentheses, such as "($  345.56)," and a zero result as "$0."
\# "'literal text'" 'text' (literal text) Inserts literal text in the result. Enclose the text in apostrophes. For example, {= {price}*8.1% \# "$##0.00 '= sales tax' "} includes the text "= sales tax" in the field result.
  `sequence` (sequence value) Includes the value of a sequence such as the current chapter number. Enclose the sequence identifier in accents grave (`). The result is displayed in arabic format. For example, {CREATEDATE \ @ "M/d/yy 'is the creation date of Chapter' `chapter`"} gives a result such as "7/22/93 is the creation date of Chapter 2."
  character Includes any other character - space, hyphen (-), asterisk (*), and so forth - in a date-time picture. For example, the field {DATE \ @ "HH:mm MMM-d, yy"} adds a colon and hyphen to the field result. Note that the character must be something other than the picture characters already reserved by the system, both those above and those set forth in the date formatting pictures.
\# "(###) ###-####" phone number Source: 6082769644

Picture "(###) ###-####"

Result (608)276-9644

For more, see Formatting Word Fields with Switches by Graham Mayor, MVP.

Word Help topics:

Word 2000

bullet

Dictionary-style headers

bullet

Fields

Word 97

bullet

Fields

bullet

Dictionary-style headers

 

 

 
Tip Tip  

The following is from the Chapter on Numbering:

Create Sequence Fields for Interrogatories and More

Microsoft Reference on Sequence Fields

Sequence fields are the first method that Word developed for automatic numbering and, in the words of John McGhie, the most robust. They are virtually unbreakable. Here is a link to the Microsoft Office reference page for them in Word 2010. As far as I know, the syntax and the switches have remained unchanged since before Windows.

{ SEQ Identifier [Bookmark ] [Switches ] }

A Sequence field tracks differently numbered lists within a document. Combining Sequence fields and AutoText entries give you a fast and easy way to insert Interrogatories, Requests for Production, and Requests for Admission.

Practice: Use Sequence Fields

  1. Type INTERROGATORY NO. followed by a space.
  2. Press CTRL+F9 to insert field characters.
  3. Type SEQ Rog within the field characters.

 

Note Note  The "Rog" in this example is the name of the Interrogatory numbering scheme. This name will keep this numbering scheme unique from any other schemes that may be running in the document. See Tip below for more information. It is the "Identifier" in the syntax shown.

  1. Press F9 to update the field. A number "1" should appear.
  2. Select INTERROGATORY NO. 1, and press ALT+F3 to create a new AutoText entry.
  3. Type rog for the AutoText entry name, and click OK.
  4. Type Request for ANSWER followed by a space.
  5. Press CTRL+F9 to insert field characters.
  6. Type SEQ Ans within the field characters.
  7. Select ANSWER 1, and press ALT+F3 to create a new AutoText entry.
  8. Type Ans for the AutoText entry name, and click OK.
  9. Type Ans and press F3. The next sequential number for an Answer appears.
  10. Press ENTER and type rog and press F3. The next sequential Interrogatory appears.

To use the AutoText entry, simply type rog and press F3.

 

Tip Tip  Follow the same steps (above) to create Request for Production or Request for Admissions. The only difference would be in Step 3, you would change the "rog" to "rpf" or "rfa". This will keep unique numbering schemes running in the same document. Therefore, you could have an Interrogatory No.1 as well as Request for Production No.1. Keep in mind that if you cut, copy or paste sequence codes, you'll need to select them and press F9 to update the field codes. They do not update automatically.

The Bookmark part of the syntax { SEQ Identifier [Bookmark ] [Switches ] } is optional and is when adding Cross-Reference text as part of the SEQ field.

The Switches are also optional and are as follows:

\c

Repeats the closest preceding sequence number. This is useful for inserting chapter numbers in headers or footers.

\h

Hides the field result. Use it to refer to a Seq field in a cross-reference without printing the number. For example, you might want to refer to a numbered chapter but not print the chapter number. The \h switch doesn't hide the field result if a Format (\*) switch is also present.

\n

Inserts the next sequence number for the specified items. This is the default.

\r n

Resets the sequence number to the specified number n. For example, { SEQ figure \r 3 } starts figure numbering at 3.

\s

Resets the sequence number at the heading level following the "s". For example, { SEQ figure \s 2 } starts numbering at the Heading 2 style. Many fields do not update automatically or when the underlying condition changes without a little help, either a manual update using the F9 key or a macro.

Use Sequence Fields for Tickets and More

A Sequence field tracks differently numbered lists within a document. Using different sequence fields can give you the ability to print a number of tickets on a page, make a stack of pages, cut the stack into tickets and have the tickets numbered sequentially.

Question:
I've been printing tickets that require sequential numbering and have that working but I have some issues that are bigger then my knowledge.

I have a word document with a table of 6 exact cells on a full page table. In those cell areas I have been printing tickets with a list and a mail merge and updating labels. I call to an excel list of 1-2000 and then I generate all the pages through the Finish and Merge option. This all works perfect. I get 2000 individually numbered tickets to print...however...I then have six tickets printed on a page of paper with ticket numbers 1, 2, 3, 4, 5 ,6 then the next page has 7,8,9,10,11,12. This is fine but I then have to cut and stack these tickets in groups of six and at that point none of the numbering is sequential. The tickets are basically random.

Any suggestions on the best way to split the 6 regions so that the top left region would be 1-335, then the middle top would be 336-670, Then the top right would be 671-1005, then bottom left would be 1006 - 1340, Then bottom middle would be 1341-1675, then the final bottom right region would be 1676-2010?

Answer: Use Sequence Fields

  1. Instead of a merge, use a page of labels with six SEQ fields set for different sequences and with an interval of 6. The first page would be your initial set of fields with numbering 1, 35, 69, 103, 137, and 171.
  2. The first field would be { SEQ Ticket1 /r 1 /# "0000" }.
  3. The second would be { SEQ Ticket2 /r 35 /# "0000" } and so forth.
Note Remember  the { } braces for fields cannot be typed. They must be inserted by Word.

In Word 2007 and later using Insert > QuickParts > Field or Ctrl+F9.   
In Word 97-2004 use Insert > Field or Ctrl+F9.

  1. Labels are Word Tables.
  2. Create your first page, what you are using for a merge page now. Use the six SEQ fields instead of the Mail Merge field.
  3. Copy the entire table on the first page and paste it creating a second page.
  4. On the second page press Alt+F9 to toggle display of field codes.
  5. Change the fields to drop the /r switch, i.e.
    The first field on the second page would be { SEQ Ticket1 /# "0000" }.
    The second would be { SEQ Ticket2 /# "0000" }
    and so forth.
  6. Press Alt+F9 again to toggle back to field results.
  7. Then copy that page and paste until you have a total of 34 pages of tickets.
  8. Press Ctrl+A to select the entire document and press F9 to update the fields.
    You should have 2004 tickets numbered so you can cut them in sequential stacks.
    That is, the top stack would be numbered 1-34, the second stack numbered 35-68, and so forth. After you cut them, you can put the first set on top of the second, on top of the third...
  9. For larger numbers, increase the interval between each sequence and use that number of pages. What I suggested is based on 34 pages of 6 so the interval is 34. For each additional page of 6 you would increase that interval between the starting numbers by one.

A similar question arose except with ten tickets per page and 500 tickets. The same analysis applies. Alternatives using Mail Merge are offered there that are easier but do not provide for sequentially numbered stacks of tickets.

  1. Figure the number of pages to get the separation between the sequences. 500 tickets / 10 per page = 50 pages.
  2. That 50 is the value needed to separate the different sequences on each ticket.
  3. The first page starts the sequences.
  4. The following pages use those sequences but omit the starting number.

 

Bar Code Fields

Word 97-2003 have easy access to a BARCODE field that generates an old PostNet field. This field is not only not useful but may cause problems with the Post Office. In Word 2007 and later the field generates a bar code but is not written for you by Word. It still generates the (dysfunctional) bar code in later versions of Word.

Word 2013/365 added two fields that are not much documented. These fields do not work in earlier versions of Word and will, in some circumstances generate an error message if a document with such a field is opened in earlier versions. (This won't prevent opening the document or hurt the contents.) These fields are:

bullet DisplayBarCode Field - This field lets you insert various kinds of bar codes and has switches for orientation and size as well as error-correction level.  Includes the following kinds of Bar Codes:
bulletQR - Quick Response
bulletCASE / ITF14 - track shipping
bulletCODE128
bulletCODE39
bulletJPPOST
bulletEAN8/EAN13
bulletJAN8/JAN13
bulletUPCA/UPCE
bulletITF14
bulletNW7

Click to download the Add-In that produced this QR code.Download the free BarCode Add-In for easy implementation of this field. The QR code shown was generated using that Add-In.





 

 

bullet MergeBarCode Field - Works like the MergeCode field except it has extra arguments that tell the field what kind of bar code to display. I believe you could do the same thing with the DisplayBarCode field using a mergefield as one of the arguments.

 

Using vba (macros -- Visual Basic for Applications) to insert fields in documents
Insert a field using vba

The following will insert a StyleRef Field . The name of the style needs to be put in the string strStyleName. This can get much more complex.

 With Selection

.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False, Text:="StyleRef " & strStyleName
.Fields.Update

End With

Insert a (nested) Sequence field using vba

Sub InsertOddSeqField()
' Paul Edstein (macropod) Microsoft Community Answers
'Insert nested field
Application.ScreenUpdating = False
ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
With Selection
  .Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
    PreserveFormatting:=False, Text:="=*2-1 \# 0"
  .MoveRight Unit:=wdCharacter, Count:=3
  .Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
    PreserveFormatting:=False, Text:="SEQ MyList"
  .Fields.Update
End With
ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
Application.ScreenUpdating = True
End Sub

First, generally you may want to simply create a field and perhaps edit it in the user interFace. If you need to repeat that field often, you will save it as an AutoText Entry (Building Block) for easy reuse. There may be times, though, when you want to be able to place a field into a document using a macro.

 

Troubleshooting Fields — Issues To Watch Out For

  1. Insertion of field braces {} using the keyboard instead of the Ctrl+F9 key combination { }. With show field codes on, you won't see the difference when you are typing until you try to turn the field codes off. They may look the same to you and me but to Word they are very different! You can't enter fields manually using the braces on the keyboard. If you did this by mistake, cut your text, delete the typed braces, insert new braces using Ctrl+F9, and paste your text.
  2. Fields in headers/footers. You cannot use a document variable field in a header/footer. It will crash Word.
  3. Page numbering fields. Word doesn't really have pages, it just cuts things up into pages as it prints. There are times when it will start printing before it has finished cutting and the page numbers (especially the NUMPAGES) will be wrong.
  4. Fields not updating. They may be locked. Most fields don't update when you open, edit, or close a document, but rather when you print it.
  5. ASK fields and FILLIN fields - double prompts. You are asked twice to answer each field. See the Microsoft Knowledge Base Articles Q238978 and Q164547.
  6. What happens to field results when you save as text? See the Microsoft Knowledge Base Article Q211688.
  7. Your computer's BIOS may have special uses for function keys, hijacking their use with fields. If so, there will be a special shift key (Fn). So, instead of Ctrl+F9, you would use Fn+Ctrl+F9.
  8. When discussing field codes in the forums or an email it can be helpful to actually see the code. When you copy a field code from Word and paste elsewhere (as in a forum) you simply get the field result.

    Related online thread: Convert field codes to text for posting | Windows Secrets Lounge.

    Here is a macro from Paul Edstein (macropod). I've been using it since 2004 when I want to look at or share a field code. (Truly sharing a complex nested field code requires sending a document with the code in it, though.)

    Sub FieldCodeToString()
    '
    ' From Paul Edstein (macropod)
    ' Found at http://www.gmayor.com/export_field.htm
    ' Posted to the newsgroup on 15 April 2004 by macropod
    ' Converts a Word field code to a string (in the clipboard)
    '
    Dim Fieldstring As String
    Dim NewString As String
    Dim CurrChar As String
    Dim CurrSetting As Boolean
    Dim fcDisplay As Object
    Dim MyData As DataObject
    Dim X As Long
    '
    NewString = ""
    Set fcDisplay = ActiveWindow.View
    Application.ScreenUpdating = False
    CurrSetting = fcDisplay.ShowFieldCodes
    '
    If CurrSetting <> True Then _
    fcDisplay.ShowFieldCodes = True
    Fieldstring = Selection.Text
    '
    For X = 1 To Len(Fieldstring)
    CurrChar = Mid(Fieldstring, X, 1)
    Select Case CurrChar
    Case Chr(19)
    CurrChar = "{"
    Case Chr(21)
    CurrChar = "}"
    Case Else
    End Select
    NewString = NewString + CurrChar
    Next X
    '
    Set MyData = New DataObject
    MyData.SetText NewString
    MyData.PutInClipboard
    fcDisplay.ShowFieldCodes = CurrSetting
    End Sub


    This code and the reverse (string to code) can be found on Graham Mayor's site with directions on how to use them.

Using this code which displays and then hides field codes will trigger a minor bug in Word 2013 that zooms the next document created/opened to 10%.
 

Answers to question on footer field:

{IF {PAGE} < {NUMPAGES} "Page {PAGE} of {NUMPAGES}" "{FILENAME \p}" }

On the last page, this will print the full document name. In a four-page document, on page three, it will print "Page 3 of 4." (That's right, it prints the same thing under the same circumstances as did our other field! The order of the truetext and falsetext have been reversed because if "{PAGE} < {NUMPAGES}" is true then "{PAGE} = {NUMPAGES}" must be false.

To put "truetext" only on the third page of the document the field would look like:

{IF {PAGE} = 3 "truetext" }

To put "truetext" only on the next-to-the-last page the field could look like:

{IF {PAGE} = { = {NUMPAGES} - 1 }" "truetext" }

 

 

 

 

There is no corresponding Chapter on the Microsoft website.

Hit Counter page views since 14 April 2004