Method UpdateFields
UpdateFields(WordDocument, DocumentSpan, FieldUpdateOptions?)
Updates every field whose extent meets a span, as one undoable edit (Word's F9): a table of contents is rebuilt from the headings as they are now (their bookmarks reused); any other field gets its evaluated result; PAGEREF takes PageReference; PAGE and NUMPAGES are left to layout; a field that cannot be evaluated keeps its result.
public static DocumentEdit UpdateFields(this WordDocument document, DocumentSpan span, FieldUpdateOptions? options = null)
Parameters
documentWordDocumentThe document.
spanDocumentSpanThe selection; a caret updates the fields it is in or next to.
optionsFieldUpdateOptionsThe evaluation's clock, culture and page references, or null for invariant defaults.
Returns
- DocumentEdit
The edit (empty when no field changed); the caret stays where the span ends.
Exceptions
- ArgumentNullException
documentis null.- ArgumentException
An end of the span is not in
document.