Click here for more information about the book at Amazon.com.


Click here for more information about the book at Amazon.com.


Click here for more information about the book at Amazon.com.

Click for information on Amazon.com about this book.

other books
about using Word

 

 

 

 

Flying Pillcrow - trademark of Madison Wisconsin Criminal Defense Lawyer Charles Kenyon'n Word sites - symbolizing the wish to make Word fly!

 

Users Guide
Tutorials

Basic Formatting

Complex Documents
Tables of Contents
Tables of Authorities
Cross-References

Confidentiality
and MetaData

Numbering

Sections and
Section Breaks

Headers and Footers

Styles

Tables

Track Changes
& Compare
Documents

Template Basics
Normal.dot
User
Workgroup
Document
Global

Troubleshooting

Document
Corruption

Third Party
Vendors
Directory

Flying Pillcrow - trademark of Madison Wisconsin Criminal Defense Lawyer Charles Kenyon'n Word sites - symbolizing the wish to make Word fly!

 

 

 

Other Word
Links

Frequently
Asked
Questions

Books
about
Microsoft Word

Microsoft Word
Free
Downloads
:
Add-Ins
Tutorials
Templates

Links

 

Flying Pillcrow - trademark of Madison Wisconsin Criminal Defense Lawyer Charles Kenyon'n Word sites - symbolizing the wish to make Word fly!

 

 

This site maintained
as a hobby
as part of my
 criminal defense
attorney web site
 in
 Madison, Wisconsin.

 

 

 

Flying Pillcrow - trademark of Madison Wisconsin Criminal Defense Lawyer Charles Kenyon'n Word sites - symbolizing the wish to make Word fly!

 

Users Guide
Tutorials

Basic Formatting

Complex Documents
Tables of Contents
Tables of Authorities
Cross-References

Confidentiality
and MetaData

Numbering

Sections and
Section Breaks

Headers and Footers

Styles

Tables

Track Changes
& Compare
Documents

Template Basics
Normal.dot
User
Workgroup
Document
Global

Troubleshooting

Document
Corruption

Third Party
Vendors
Directory

Flying Pillcrow - trademark of Madison Wisconsin Criminal Defense Lawyer Charles Kenyon'n Word sites - symbolizing the wish to make Word fly!

 

 

 

Other Word
Links

Frequently
Asked
Questions

Books
about
Microsoft Word

Microsoft Word
Free
Downloads
:
Add-Ins
Tutorials
Templates

Links

 

Flying Pillcrow - trademark of Madison Wisconsin Criminal Defense Lawyer Charles Kenyon'n Word sites - symbolizing the wish to make Word fly!

 

 

This site maintained
as a hobby
as part of my
 criminal defense
attorney web site
 in
 Madison, Wisconsin.

 

 

 

 

 

 

 

Using { Fields } in Microsoft Word

VERY ROUGH DRAFT - not ready for prime time - this is in the site right now primarily for the Additional Written Resources.

by Charles Kyle Kenyon, Esq.

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 should have reviewed 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:
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.
bulletInsert a date field.
bulletInsert calculated date fields.
bulletInsert a page number.
bulletInsert special page numbers and calculated page numbers.
bulletInsert document information in your document body or headers and footers.
bulletUse an ASK field, bookmarks and related cross-references.
bulletUse Function and ShortCut keys to manipulate fields
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.

Other Chapters Related to Topics Covered in this Lesson

bulletNumbering - Sequence Fields
bulletComplex Legal Documents (Footnotes, Endnotes, Bookmarks, Cross-References)

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 
bulletThe mailmerge.fields newsgroup on the Microsoft news server.
bulletMVP FAQ index Fields
bulletFields Revealed by Sherry Kappel of Microsystems.
bulletHow 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 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 : 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 Beyond Mail Merge - Alternatives to Word's Built-in Feature **

** These articles are on a subscribers'-only site. However, you can sign up for a free issue and get 30 days on-line privileges.

bulletMail 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 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 Word Field Calculations - you have to see this to believe it - manipulate fields to get what you want - by Macropod
bulletPage 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 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 
bulletMacroButton 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
bulletStyleRef Field Tutorial - two-page download
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
bullet Useful StyleRef Field Tricks by Suzanne S. Barnhill, MVP
bullet Field Macros - Greg Maxey's page on using vba to manipulate fields

 
bulletMicrosoft Knowledge Base: 
bulletUsing the {ASK} Field Inside an {IF} Field - Article Q211664
bulletWhich Fields get Automatically Updated - and When - Article 89953
bulletHow to Create Two Page Numbering Schemes In One Document - Article 212313
bullet {ASK} fields and {FILLIN} fields - double prompts. You are asked twice to answer each field. See the Microsoft Knowledge Base Articles Q238978 and Q164547.
bulletWhat happens to field results when you save as text? Article Q211688.
bulletHow to Create an Automated Form with Fill-In Fields. Articles Q238275 and Q142213
bulletQ95133 WD: How to Create a Checked/Blank Check Box Using FILLIN Fields
 
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 - zip file - a Word document by Macropod - examples of very complex calculated date fields that you can modify to suit your purposes
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
bulletLetterhead - Textboxes and Styles tutorial - StyleRef field used to copy information from address and reference lines to continuation header
bulletLegal Toolbars - date fields stored as AutoText entries available on drop-down menu
 
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.

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.

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

(so far, just the heading)

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.

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" \*MERGEFORMAT }

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
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
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

* 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.

** 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.

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 the best way 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.
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

  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. 

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.

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 is Word's primary way of repeating variable text in a document.
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.
  3. Select Overview, and apply Heading 2.
  4. Select Unsolicited Proposals, Solicited Proposals and General. Apply Heading 3.
  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, choose Cross-reference.

The Cross Reference dialog

  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.

The Cross Reference dialog with a Heading selected

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

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.)

 

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.)

This is still in its infancy. See my download page for examples of ASK fields.

MacroButton Fields - not just for macros anymore!

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. There are probably limits on length. Instead of (or in addition to) the DisplayText you can insert a picture or icon to act as a visual button for your macro.

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.

To insert a MacroButton field like this in your document:

Insert => Field ... 

Where it says Field: type "MacroButton NoMacro prompt." The "MacroButton" is the name of the field. "NoMacro" is the name of the macro - 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.

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.

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 TeemplateListLoad Releases\Release - blank}

{ Macrobutton TeemplateListLoad Log}

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

Sub TemplateListLoad()
'   Based on ideas from http://www.mvps.org/word/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 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.

Additional references on MacroButton fields

bulletHow to create a template that makes it easy for users to “fill in the blanks”, without doing any programming
bulletEnable a user to double-click text in a document to change its value
bulletRun a macro when a user double-clicks a button in the document
bulletMacroButton field reference on MS site
bulletCheckbox AddIn - a tutorial on the use of MacroButton fields together with AutoText and Macros to insert checkboxes into non-protected documents. 
bulletUsing MacroButton Fields by Graham Mayor, Jonathan West and Hak-lok NG
bulletUsing {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

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)

 

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. 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 => Field... => Links and References (left window) => STYLEREF (bottom of right window) => Options (button)

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.

Calculated Fields - Conditional Fields

A calculated field is one that does some kind of calculat