How create HyperLink to local bookmark with JS? (href=#bookmarkname)

Hi, friends. I am unable to create a valid bookmark link in the document.

ApiRange.AddHyperlink(sLink, sScreenTipText) → { ApiHyperlink | null }

with sLink = ‘#bookmarkname’ not create correct link.

When clicking on this link, the cursor does not move to the bookmark

Hello @XOMRKOB

I’m afraid AddHyperlink is not a suitable option here as it requires an actual link to work.

If I understand your goal correctly, you want to have a link to a bookmark in the document when clicking which cursor moves to the position of required bookmark. For that you can create a cross-reference link to the bookmark with method AddBookmarkCrossRef.

1 Like

Спасибо, Константин.

I hope it helps.

Please note that official languages of this forum are English and Chinese.