Skip to main content

Word.Hyperlink

Word.Hyperlink is an object type of the Word module (Office.word(iframe)). 8 methods.

Generated from the SDK type definitions

Word · 14 object types · 259 methods · namespace Word. This reference is generated from the API document artifact (sdk-api-doc.html) produced with the SDK build. Descriptions are the editor's API comments as published. Pin the SDK and Office versions together and regenerate when either changes.

Remarks

Methods

MethodDescription
delete()Deletes the hyperlink.
exists()Returns whether the hyperlink exists.
getId()Returns the hyperlink ID.
getLinkType()Returns the link type.
getRange()Returns the range of the display text the link is attached to.
getTooltip()Returns the link tooltip (the description shown on mouse hover).
getUrl()Returns the link target address.
update(options)Updates the hyperlink's address, tooltip and display text.

Method details

delete()

Deletes the hyperlink. - The display text remains in the document.

delete(): Promise<void>;

Returns

Promise<void>

exists()

Returns whether the hyperlink exists.

exists(): Promise<boolean>;

Returns

Promise<boolean> - true if it exists

getId()

Returns the hyperlink ID.

getId(): Promise<string | null>;

Returns

Promise<string | null> - hyperlink ID, or null if not yet inserted

getLinkType()

Returns the link type.

getLinkType(): Promise<HyperlinkType>;

Returns

Promise<HyperlinkType> - link type (link/mailto/bookmark)

getRange()

Returns the range of the display text the link is attached to. - The link start/end markers are not included. Editing the returned range changes only the text while keeping the link.

getRange(): Promise<Range>;

Returns

Promise<Range> - display text range

getTooltip()

Returns the link tooltip (the description shown on mouse hover).

getTooltip(): Promise<string | null>;

Returns

Promise<string | null> - tooltip, or null if not set

getUrl()

Returns the link target address. - Bookmarks are returned as "#name". Web addresses entered without a protocol are returned as "https://…".

getUrl(): Promise<string>;

Returns

Promise<string> - destination url

update(options)

Updates the hyperlink's address, tooltip and display text. - Specify at least one field to change. Giving only url keeps the display text; giving displayText replaces it.

update(options: { url?: string; tooltip?: string; displayText?: string }): Promise<void>;

Parameters

NameTypeDescription
options{ url?: string; tooltip?: string; displayText?: string }update options (all fields optional, at least one required)
options.url (optional)stringnew URL (web http(s):// · email mailto: · bookmark #name) (default: current value)
options.tooltip (optional)stringnew tooltip (omitted: keeps the current tooltip, but becomes the new url when url is also changed)
options.displayText (optional)stringnew display text (if given, the visible text is replaced) (default: current value)

Returns

Promise<void>