Hyperlinks showing as code in Word (Field Codes)
Audience – Tier 1, Tier 2
Dealing with Fields in Microsoft Word
Topic: { Fields } in Microsoft Word
Word Versions: Word 97 - Microsoft 365
This does not apply to Word Online, IOS, or Android although most fields work in those versions. It does apply to Word on Mac and Windows.
Level: Beginner-Intermediate
Purpose: This is not a thorough exploration of fields. It is intended to be a short view of what can be done when using fields. There is a list of good references at the bottom of this article.
What is a field?
A field is a method of having dynamic content in Word.
That is, content that changed depending on other information in the document or the user's system.
It is not a Content Control although Content Controls can be included in fields. Fields are an old technology in Word and have changed little over the years.
A few examples are:
- the PAGE field for page numbering,
- the cross-reference (REF) field to link to contents elsewhere,
- the MERGEFIELD for use in Mail Merge,
- the StyleRef Field to repeat text formatted in a given style,
- the TOC Field that can be used to insert a Table of Contents or a Table of Figures in a document
- the SEQuence Field for one kind of automatic numbering, and
- the IF Field for making conditional text or parts in a document.
How can I insert a Field in a document?
You cannot simply type the field code! Only Word can create a Word field.
You can call up the Insert Field dialog
There are a number of ways to do this. In menu (older) versions of Word, it is Insert > Field.
In Ribbon versions on Windows, you can find this under Insert > Quick Parts > Fields.In Ribbon versions on the Mac, I believe it is still Insert > Field.
You can use the keyboard shortcuts to call up this dialog:
- Windows version: Alt+I, F
- Mac version: Opt+I,F
There are keyboard shortcuts for a few particular fields, shown below.
Numerous commands and buttons insert particular fields. You may never see the field itself.
- Date
- Table of Contents
- Cross-Reference
- Hyperlink
- Index
Although you cannot simply type a field, you can insert a blank field and type the name and switches. (Ctrl+F9 keyboard shortcut)
This keyboard shortcut inserts a matched pair of Field delimiter braces { } into which you can type. This requires that you know the field name and syntax as well as switches. It is the only way to create nested fields.
Once you create a complex field the way you want it, you can select it and save it as AutoText or another Building Block for reuse.
(You could even save as a formatted AutoCorrect entry!)
Where can I find documentation on fields?
Here is the Microsoft documentation on fields: Field codes in Word
Here is my page on fields: Using Fields in Microsoft Word
(more further on in the page)
How can I see what the coding of a field is in Word?
Here is what a field looks like in a document:
Wednesday, 5 January 2022
It may have shading applied:
That really gives you no idea of what the field is doing, only what it is displaying. Word does let you look under the hood very easily, though. There are two quick methods:
Toggle Field Code Command - Shift+F9 keyboard shortcut
Toggle Field Code Display - Alt+F9 keyboard shortcut or set in Options/Preferences
If you use Shift+F9, pressing F9 will return you to the result and hide the code.
Alt+F9 is a toggle of a setting in Word and applies until you toggle back. (You will continue to see field codes rather than the results until the setting is toggled back to display of results.)
Toggling field code display is the only way to create nested fields (without macros).
You can also set this in Word Options (Advanced) but the keyboard shortcut is so handy, why bother. If you want to bother, here is the dialog box under File > Options > Advanced:
There is an option in Word to print field codes.
- If you have that option checked, field codes will print instead of the field result (text) even if they are not displayed in the document.
- If you have the option checked/toggled to display field codes, they will print regardless of the setting for printing field codes.
What are the function keys and keyboard shortcuts for manipulation of Fields?
There are a number, and some of the handiest ones do not seem to be documented by Microsoft. They can vary by operating system as well.
Here is my writing on that on my website: Function Keys and Keyboard Shortcuts that Manipulate Fields. The following table is from that page.
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 | Cmd+F9 |
Alt+Shift+F9 | Run Macro (MacroButton Field Only) | Opt+Shift+F9 |
Ctrl+Shift+F9 | 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 | Lock Field (prevent manual or automatic update) | Cmd+F11 |
Ctrl+Shift+F11 | Unlock Field (allow updating) | Cmd+Shift+F11 |
Alt+I, F | Insert Field (Dialog Box) | 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 |
* 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. This is demonstrated above. For more about this, look at Display of Field Codes in my page.
** 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 still see the field codes.
*** Probably not the field you want to insert, though. This gives the continuously updating field. See my page on 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. See Hijacked Function Keys. Try adding the Fn shift key to the key combination.
See also MVP Lene Fredborg's article: Word Fields – Useful Keyboard Shortcuts – Word Macros and Tips
(end of quoted material)
Escalation:
If an escalation is necessary, please escalate to Tier 2 as first POC, if Tier 2 is unavailable please escalate to SME.