Table of Contents

Method SetResult

Namespace
DocWright.Dom.Fields
Assembly
DocWright.Dom.dll

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

text string

The replacement text. An empty string leaves the result region empty.

format CharacterFormat

The formatting for the replacement, or null to inherit ResultFormat.

Returns

TextRun

The inserted run, or null when text was 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

text is null.

InvalidOperationException

The region has already been edited away, or it has no result region.