Skip to main content

SetLink

Sets the hyperlink address.

Syntax​

expression.SetLink(sLink);

expression - A variable that represents an ApiHyperlink class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
sLinkRequiredstringThe hyperlink address.

Returns​

boolean

Example​

Change the URL of a hyperlink in a document.

// How do I update the address a hyperlink points to in a document?

// Point an existing hyperlink to a different website in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("Visit ONLYOFFICE for developers");
paragraph.AddElement(run);
let hyperlink = paragraph.AddHyperlink("https://www.onlyoffice.com");
hyperlink.SetLink("https://api.onlyoffice.com");