w:instrText (Field Instruction Text)
Contains the instruction string (e.g., 'TOC \o 1-3') for a complex field between begin and end fldChar elements.
Parent elements
Description
w:instrText carries the instruction text of a complex field (between the begin and separate w:fldChar markers). It is defined in ECMA-376 Part 1 §17.16.23.
The field instruction text uses the same syntax as simple field instructions (e.g. PAGE, DATE \@ "d MMMM yyyy", TOC \o "1-3" \h). Use xml:space="preserve" to ensure leading/trailing spaces in the instruction are not stripped by XML parsers.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
xml:space |
XML standard | preserve |
Preserves surrounding whitespace in the instruction text. Always recommended. |
Examples
<w:r>
<w:instrText xml:space="preserve"> DATE \@ "d MMMM yyyy" </w:instrText>
</w:r>
new Run(
new FieldCode(@" DATE \@ ""d MMMM yyyy"" ")
{ Space = SpaceProcessingModeValues.Preserve });
Notes
- Runs carrying
w:instrTextcommonly also carryw:rPrwithw:vanishso the raw instruction is not displayed in normal view. - For simple (non-updateable) fields, prefer
w:fldSimplewhich uses a single element rather than the three-run begin/separate/end pattern.