Method InsertHyperlink
InsertHyperlink(WordDocument, DocumentPosition, string, HyperlinkTarget)
Inserts link text at a position, as one run in the Hyperlink style, and makes it a hyperlink.
public static DocumentEdit InsertHyperlink(this WordDocument document, DocumentPosition at, string text, HyperlinkTarget target)
Parameters
documentWordDocumentThe document that holds the position.
atDocumentPositionWhere to insert.
textstringThe text to display: one line, tabs allowed.
targetHyperlinkTargetWhere the link goes.
Returns
- DocumentEdit
The edit; After is just past the text.
Exceptions
- ArgumentNullException
document,textortargetis null.- ArgumentException
The position is not in
documentor falls inside a surrogate pair; the text is empty or holds a line break or control character; or the target names a bookmark the document does not have.- InvalidOperationException
The position is in a shape's text box, inside content a reader synthesized, or in a content control that refuses free text.