Method ChangeHyperlink
ChangeHyperlink(WordDocument, HyperlinkStart, HyperlinkTarget, string?)
Gives a hyperlink a new target and tooltip and, optionally, new text.
public static DocumentEdit ChangeHyperlink(this WordDocument document, HyperlinkStart link, HyperlinkTarget target, string? text = null)
Parameters
documentWordDocumentThe document that holds the link.
linkHyperlinkStartThe link's start marker.
targetHyperlinkTargetThe new target.
textstringThe new text (one line, tabs allowed), formatted like the link's first run; or null to keep the text.
Returns
Exceptions
- ArgumentNullException
document,linkortargetis null.- ArgumentException
The link is not in a paragraph of
document; 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 link is in a shape's text box, or new text is given for a link that holds more than text, tabs, breaks and bookmarks (a picture, a note reference, a field).