Method InsertField
InsertField(WordDocument, DocumentPosition, string, FieldUpdateOptions?)
Inserts a field (Word's complex field: begin, instruction, separator, result, end) at a position, its result what the field evaluates to now; a field the layout evaluates per page (PAGE, NUMPAGES) shows the page it is drawn on.
public static DocumentEdit InsertField(this WordDocument document, DocumentPosition at, string instruction, FieldUpdateOptions? options = null)
Parameters
documentWordDocumentThe document that holds the position.
atDocumentPositionWhere the field goes.
instructionstringThe instruction, such as
PAGE,NUMPAGESorDATE @ "d MMMM yyyy": 1 to MaxFieldInstructionLength characters, no control characters.optionsFieldUpdateOptionsThe evaluation's culture and clock (a DATE field's value), or null for invariant defaults.
Returns
- DocumentEdit
The edit; After is just past the field.
Exceptions
- ArgumentNullException
documentorinstructionis null.- ArgumentException
The position is not in
document; the instruction is empty, too long or holds a control character.- InvalidOperationException
The position is in a shape's text box or inside content a reader synthesized.