From automatically inserting and formatting data to marking the place someone needs to type into a template, Word fields are the tool to use. Unfortunately, as useful as they are, Word doesn’t make field codes easy to find and a quick first glance at the field codes dialog won’t exactly enlighten you to their potential uses. However, we’re about to lift the lid on field codes and introduce you to creating and using them and some handy things you can do with them.
What Are Field Codes?
Field codes are generally hidden so you might have used them before without knowing they were even there. They are used extensively in mail merge as placeholders in the merge document, marking where the fields from the data file will appear when the document is merged. However, merge is only a small sampling of what field codes are capable of doing.
One handy field code is the date field code. To add one to your document press Alt + Shift + D
and the current date appears in your document. This is a field code that marks the place where the current date will be displayed in the document. Because it is a field code and not a hard-coded date, tomorrow it will read a different day.
To see the underlying code, click on the date and press Shift + F9. You will see something like:
{ DATE @ "M/d/yyyy"}
This code inserts the date and formats it according to the format codes. You can change the codes, for example to read:
“MMM dd, yy”
Press Shift + F9
to hide the field code again and press F9
to update it. If today’s date is January 10, 2008, your field code would have read 1/10/2008 and will now read Jan 10, 08.
DIY Field Codes
Instead of pressing Alt + Shift + D
you could type the field code yourself. To do so, press Control + F9
to type the curly braces — these can’t be entered from the keyboard and have to be typed this way. Now, click inside the braces and type the field code — for example, type:
{ DATE @ "dd MMMM, yyyy"}
Press Shift + F9
to hide the code and press F9
to update it. Note that it’s vital you use the correct case for the formatting — lower case m is used for minute format, not months, for example.
Shortcut Keys
There are some handy keys for working with field codes:
Shift + F9
– Toggles between displaying the selected field code and its results
Control + F9
– Inserts a set of field code markers (curly braces)
F9
– Updates a field code, and when used in combination with Control + A
, all field codes in the document are updated
Alt + F9
– Toggles between displaying all the field codes in a document and displaying their results
Field Codes Dialog
In addition to typing your own field codes, you can insert field codes using the Field Codes dialog. From the Ribbon choose Insert > Quick Parts > Field to open the field codes dialog.
From the Categories list choose Date and Time and from the Field names list choose Date. If the button in the bottom corner reads Hide Codes, click it and choose a format from the list displayed. Click Ok to add the field to your document.
Template Prompts
One interesting use for field codes is as a marker for text to be inserted into a template. Consider the situation where you are making a template for someone else to use.
You can mark where they are to enter data with a special field code and the user will see a prompt inviting them to click and add their text. When they do so, the field code disappears to be replaced with their text.
This feature uses the MACROBUTTON field. Its real use is to run a named macro when the field is clicked. However if there is no macro to match the name in the field code it simply disappears. This is the behaviour you will use to make your [Click and type]
block.
To do this, click where your user should type their text. Choose Insert > Quick Parts Field and from the Categories list choose Document Automation and from the Field names list choose Macrobutton. Click the Field Codes button to fill the Field Codes box. Edit the entry so it reads:
MACROBUTTON noname [Click and type the Customer's Name]
The entry noname can be anything as long as there is no macro with this name in the current file or the current template. The brackets are simply markers to indicate that this is a prompt — they don’t need to be there and they could be replaced with anything or removed entirely.
Click OK and test the result. Press the Undo button to undo your typing and redisplay the field code.
You can create as many click here blocks in your document as you like and they can all use the same non existent macro name.