This topic describes how to obtain hyperlinks and insert a hyperlink at a specified location when you use a text document.
Obtain hyperlinks
Obtain all hyperlinks in a document.
Syntax
Expression.ActiveDocument.Hyperlinks
Expression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain hyperlink objects. const hyperlinks = await app.ActiveDocument.Hyperlinks; }
Insert a hyperlink
Insert a hyperlink at a specified location.
Syntax
Expression.ActiveDocument.Hyperlinks.Add({ Address, TextToDisplay })
Expression: the document type application object.
Parameters
Parameter
Type
Required
Description
Address
String
Yes
The address of the hyperlink to be inserted.
TextToDisplay
String
No
The display text of the hyperlink.
Example
async function example() { await instance.ready(); const app = instance.Application; // Insert a hyperlink at the specified location. await app.ActiveDocument.Hyperlinks.Add({ Address: 'https://www.aliyun.com/', // The address of the hyperlink to be inserted. TextToDisplay: 'Alibaba Cloud official website', // The display text of the hyperlink. }); }