Table of Contents

Method ChangeHyperlink

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

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

document WordDocument

The document that holds the link.

link HyperlinkStart

The link's start marker.

target HyperlinkTarget

The new target.

text string

The new text (one line, tabs allowed), formatted like the link's first run; or null to keep the text.

Returns

DocumentEdit

The edit; Before is the link's start and After its end.

Exceptions

ArgumentNullException

document, link or target is 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).