A field is text that Word works out: a page number, a date, a table of contents. The file stores the instruction and the last result, so a reader that does not understand fields still has text to show.
Simple fields
w:fldSimple holds the instruction in an attribute and the result as runs.
<w:fldSimple w:instr=" PAGE ">
<w:r><w:t>4</w:t></w:r>
</w:fldSimple>
Complex fields
A complex field is spread over runs, marked by three w:fldChar elements. It
can span paragraphs, and fields can nest: a table of contents is one field whose result is
many paragraphs, each with fields of its own.
<w:r><w:fldChar w:fldCharType="begin"/></w:r>
<w:r><w:instrText xml:space="preserve"> NUMPAGES </w:instrText></w:r>
<w:r><w:fldChar w:fldCharType="separate"/></w:r>
<w:r><w:t>12</w:t></w:r>
<w:r><w:fldChar w:fldCharType="end"/></w:r>
| Attribute of w:fldChar | Meaning |
|---|---|
w:fldCharType | begin, separate or end. A field with no separator has no stored result. |
w:dirty | The result is out of date and should be recalculated. |
w:fldLock | The field is locked against updating. |
Common field codes
The instruction starts with the field’s name, then arguments and switches (a backslash and a letter).
| Field | Result |
|---|---|
PAGE, NUMPAGES, SECTION | Page number, number of pages, section number. |
DATE, TIME, CREATEDATE, SAVEDATE, PRINTDATE | Dates and times, with a format in the \@ switch. |
TOC | A table of contents, from heading styles or outline levels. |
HYPERLINK | A link: a target in quotes, and \l for a bookmark. |
REF, PAGEREF | The text of, or page number of, a bookmark. |
SEQ | The next number in a named sequence, as used for captions. |
STYLEREF | The text of the nearest paragraph in a given style, often used in headers. |
MERGEFIELD | A mail merge field. |
AUTHOR, TITLE, FILENAME, DOCPROPERTY | Values from the document’s properties and its file. |
FORMTEXT, FORMCHECKBOX, FORMDROPDOWN | Legacy form fields, with their state in w:ffData on the opening w:fldChar. |
IF | Either of two texts, by a comparison. |
Reading a file does not run fields. Word recalculates some kinds when printing or opening, or when told to update them; other readers show the stored result.
Hyperlinks
w:hyperlink wraps the runs of the link’s text.
| Attribute | Meaning |
|---|---|
r:id | A relationship of type hyperlink: the target URI, usually with TargetMode="External". |
w:anchor | A bookmark in this document, or, with r:id, a location within the target. |
w:tooltip | Text to show on hover. |
w:history | Add the link to the list of visited links. |
A link can also be a complex field with the HYPERLINK code; the result is the
clickable text.
The explorer on this site makes only web and mail addresses clickable, opens them in a new tab, and never fetches anything itself. Other targets are listed but not followed.
Bookmarks
w:bookmarkStart has a w:id and a w:name;
w:bookmarkEnd repeats the ID. Between them is the bookmarked range, which can
cover several paragraphs. A hyperlink or REF field refers to the name. Word’s
contents tables use bookmarks named _Toc and a number, and
_GoBack is the place the editing cursor was last.