Method AddBookmark
AddBookmark(WordDocument, DocumentSpan, string)
Insert > Bookmark, Add, as one undoable edit: a bookmark round the span (empty at a caret). A bookmark of the same name, compared ignoring case, is moved here and takes the new name's case, as Word does (WQ-0111).
public static DocumentEdit AddBookmark(this WordDocument document, DocumentSpan span, string name)
Parameters
documentWordDocumentThe document.
spanDocumentSpanThe selection, or a caret.
namestringThe name (IsValidBookmarkName(string?)).
Returns
- DocumentEdit
The edit; the selection is kept.
Exceptions
- ArgumentNullException
documentornameis null.- ArgumentException
The span is not in the document, or the name is not one Word takes.
- InvalidOperationException
An end is in a shape's text box or inside synthesized content.