Table of Contents

Method InsertHyperlink

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

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

document WordDocument

The document that holds the position.

at DocumentPosition

Where to insert.

text string

The text to display: one line, tabs allowed.

target HyperlinkTarget

Where the link goes.

Returns

DocumentEdit

The edit; After is just past the text.

Exceptions

ArgumentNullException

document, text or target is null.

ArgumentException

The position is not in document or 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.