Method InsertIndex
InsertIndex(WordDocument, DocumentPosition, IndexOptions?, FieldUpdateOptions?)
Inserts an index at a position, as one undoable edit (Word's Insert Index): the INDEX field and its entries in a continuous section of their own with the columns asked for (space 720), the section after it continuous with the columns it had; mid-paragraph, the paragraph is split there.
public static DocumentEdit InsertIndex(this WordDocument document, DocumentPosition at, IndexOptions? options = null, FieldUpdateOptions? fieldOptions = null)
Parameters
documentWordDocumentThe document that holds the position.
atDocumentPositionWhere the index goes: in a paragraph directly in a section's body.
optionsIndexOptionsThe layout, or null for Word's defaults (2 columns, no headings, page numbers after ", ").
fieldOptionsFieldUpdateOptionsThe entries' page numbers (PageNumberAt) and the sort's culture, or null for none and invariant.
Returns
- DocumentEdit
The edit; After is the start of the paragraph after the index.
Exceptions
- ArgumentNullException
documentis null.- ArgumentException
The position is not in
document, or a value of the options is not defined.- ArgumentOutOfRangeException
The columns are not 1 to 4.
- InvalidOperationException
The position is not in a paragraph directly in a section's body.