如何使用 js api 删除 word 中的书签,或者这是我尝试过的删除书签的方法吗?

问题描述 投票:0回答:0

错误显示在图像中,请检查 这是使用js api从word插件中删除书签的代码

  Word.run(async (context) => {
            
            console.log("result", result);
            const range :any = context.document.getSelection();
            
            return context.sync().then(async function ()
            {
              context.load(range);
              await context.sync();
              let text = range.text
              console.log("item", item.ImageId, text);              
  
              if (item.ImageId == text) {
                console.log("item bookmark",item.bookmark)               
                range.hyperlink = "#" + item.bookmark;

                //delete the bookmark after 5 sec
                setTimeout(()=>{
                  console.log("setTimeout called")
                  range.deleteBookmark(item.bookmark)
                },5000)

              } else {
                console.log("range not matched");
              }
              
              await context.sync();
            });        
ms-word office-addins add-in
© www.soinside.com 2019 - 2024. All rights reserved.