Skip to main content

AddHyperlink

Adds a hyperlink to the current run.

Syntax

expression.AddHyperlink(sLink, sScreenTipText, sBookmarkName);

expression - A variable that represents a ApiRun class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sLinkRequiredstringThe link address.
sScreenTipTextRequiredstringThe screen tip text.
sBookmarkNameRequiredstringname of a bookmark

Returns

ApiHyperlink

Example

Turn a text run into a clickable link pointing to a web address in a document.

// How do I make a piece of text open a website when clicked in a document?

// Attach a URL and a tooltip title to a run of text so readers can follow it in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("ONLYOFFICE Document Builder");
paragraph.AddElement(run);
run.AddHyperlink("https://www.onlyoffice.com", "main page");