w:fldSimple (Simple Field)

Represents a simple field with a self-contained instruction string and optional cached display value.

Parent elements

Child elements

Description

w:fldSimple is the simple field element, combining the field instruction and its result in a single element (as opposed to the three-element begin/separate/end pattern). It is defined in ECMA-376 Part 1 §17.16.19.

The field instruction is stored in the w:instr attribute. Any run children of w:fldSimple contain the cached field result. Unlike complex fields (w:fldChar), the instruction and result are both in the same element.

Attributes

Attribute Type Possible Values Description
w:instr ST_String A field instruction string, e.g. " DATE \\@ "MMMM d, yyyy" ", " REF bookmark ". The field instruction.
w:dirty ST_OnOff true / false When true, the field result should be updated before display.
w:fldLock ST_OnOff true / false When true, the field result is locked and not updated.

Examples

<!-- Simple date field -->
<w:fldSimple w:instr=" DATE \@ "MMMM d, yyyy" ">
  <w:r>
    <w:t>January 15, 2024</w:t>
  </w:r>
</w:fldSimple>
<!-- Simple page number field (locked) -->
<w:fldSimple w:instr=" PAGE " w:fldLock="true">
  <w:r>
    <w:t>1</w:t>
  </w:r>
</w:fldSimple>

<!-- Simple document title field (marked dirty for update) -->
<w:fldSimple w:instr=" TITLE " w:dirty="true">
  <w:r>
    <w:t>My Document Title</w:t>
  </w:r>
</w:fldSimple>
<!-- Time field with multiple runs (bold + text) -->
<w:fldSimple w:instr=" TIME \@ "HH:mm:ss" ">
  <w:r>
    <w:rPr><w:b/></w:rPr>
    <w:t>14:30:45</w:t>
  </w:r>
</w:fldSimple>

<!-- Page count field -->
<w:fldSimple w:instr=" NUMPAGES ">
  <w:r>
    <w:t>10</w:t>
  </w:r>
</w:fldSimple>

Field Types (Simple vs Complex)

Aspect Simple Fields (w:fldSimple) Complex Fields (w:fldChar)
Structure Single element with w:instr attribute Three-run pattern: begin/separate/end
Updateable Read-only; result is cached only Updateable; result recalculates
Nesting Cannot nest Can nest
Use Case Display-only fields (PAGE, DATE, TITLE) Dynamic fields (TOC, REF, MERGEFIELD)
Example <w:fldSimple w:instr=" PAGE "><w:r><w:t>1</w:t></w:r></w:fldSimple> <w:fldChar w:fldCharType="begin"/> (3 runs)

Common Simple Field Instructions

Instruction Purpose Example Result
PAGE Current page number ` PAGE ` 1, 2, 3, …
NUMPAGES Total page count ` NUMPAGES ` 10 (total pages)
TITLE Document title ` TITLE ` “My Document Title”
AUTHOR Document author ` AUTHOR ` “John Doe”
DATE Date with format ` DATE \@ “d MMMM yyyy” ` January 15, 2024
TIME Time with format ` TIME \@ “HH:mm:ss” ` 14:30:45
FILENAME File name ` FILENAME ` document.docx

Attributes and Behavior

Attribute Default Effect
w:dirty false When true, the field result is stale and needs updating before display
w:fldLock false When true, the field result is locked; the instruction is not re-evaluated
w:instr (required) The field instruction string

Notes

  • Simple vs Complex: Simple fields are read-only; use them for static metadata (PAGE, DATE, AUTHOR). Complex fields are updateable; use them for dynamic content (TOC, MERGEFIELD, REF).
  • Caching: The result of a simple field is cached in the child w:r elements; the actual result depends on when the document was last generated.
  • Dirty Flag: When w:dirty="true", the field result should be refreshed before display; Word typically updates dirty fields on open.
  • Locking: When w:fldLock="true", the field instruction cannot be changed and the result won’t update; useful for fixed page numbers or static dates.
  • Instruction Syntax: Field instructions follow Word’s field code syntax, not OOXML native syntax; they are domain-specific expressions using backslash-prefixed switches.
  • Multiple Runs: Simple fields can contain multiple w:r elements; this allows mixed formatting in the result (e.g., bold DATE, colored TITLE).
  • Empty Result: A simple field with no child runs or empty text is valid; typically means the field hasn’t been evaluated yet.
  • Not Updatable: Unlike complex fields, simple fields cannot be updated by pressing F9 or Update Field in Word; they are display-only.
  • Performance: Simple fields are lightweight; they don’t require regeneration logic or complex event handling.
  • Accessibility: Ensure the field result is meaningful; empty or placeholder results may confuse screen readers.