Table of Contents

Method InsertField

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

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

document WordDocument

The document that holds the position.

at DocumentPosition

Where the field goes.

instruction string

The instruction, such as PAGE, NUMPAGES or DATE @ "d MMMM yyyy": 1 to MaxFieldInstructionLength characters, no control characters.

options FieldUpdateOptions

The 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

document or instruction is 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.