Method InsertMergeField
InsertMergeField(WordDocument, DocumentPosition, string)
Inserts a merge field at a position. One undo step.
public static DocumentEdit InsertMergeField(this WordDocument document, DocumentPosition at, string name)
Parameters
documentWordDocumentThe document that holds the position.
atDocumentPositionWhere the field goes.
namestringThe field's name: 1 to 40 letters, digits and underscores (a CSV list's name for a column, as Word makes it).
Returns
- DocumentEdit
The edit; After is just past the field.
Exceptions
- ArgumentNullException
documentornameis null.- ArgumentException
The position is not in the document, or the name is not a field name.
- InvalidOperationException
The position is in a shape's text box or inside content a reader synthesized.