Method SetResult
SetResult(string, CharacterFormat?)
Replaces the field's result with literal text, leaving the field markup, its
instruction and its w:ffData in place.
public TextRun? SetResult(string text, CharacterFormat? format = null)
Parameters
textstringThe replacement text. An empty string leaves the result region empty.
formatCharacterFormatThe formatting for the replacement, or null to inherit ResultFormat.
Returns
- TextRun
The inserted run, or null when
textwas empty.
Remarks
This is what filling in a form field does, as distinct from ReplaceWithText(string, CharacterFormat?), which removes the field altogether. The field survives as a field, so Word can still update it and a later save still carries its properties.
The replacement is one run inheriting ResultFormat. Word preserves
a replaced result's formatting character by character; this is per field, the same
simplification recorded for \* MERGEFORMAT in F5.
Exceptions
- ArgumentNullException
textis null.- InvalidOperationException
The region has already been edited away, or it has no result region.