The Office JS has provided the following function in preview, but I couldn't find any example.
Here is what I tried but it doesn't seem to work, any idea what I am missing here, since this code inserts the text but the bookmark is not created.
Word.run(function (context)
{
let range = context.document.getSelection();
return context.sync().then(function ()
{
range.insertText(`Test Bookmark`, Word.InsertLocation.replace);
let uniqueStr = new Date().getTime();
let bookmarkName = `Test_BookmarkCode_${uniqueStr}`;
range.insertBookmark(bookmarkName);
});
});
Cross posted here.
range.insertText(Test Bookmark`, Word.InsertLocation.replace);
– Idiosyncrasy