我正在开发word的加载项。我试图用文本替换书签。(我最初的目标是在书签中插入文本,但有一个错误的API中所以这是另一种方法。Earlier question link)使用office.js不能替换Word文档中的书签
这里是我的代码 -
Word.run(函数(上下文){
var doc = context.document;
//get the bookmark range object by its name
var bookmarkRange=doc.getBookmarkRangeOrNullObject("cscasenumber01");
//insert a data and replace thee bookmark range
bookmarkRange.insertText("test data",Word.InsertLocation.replace);
// Synchronize the document state by executing the queued commands,
return context.sync();
}).catch(errorHandler);
但它抛出exception.The错误跟踪消息是 - “GeneralException:GeneralException在An onymous函数(https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:211625)在AI(https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:248841) 在英尺(https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:248928) 在d(https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:248748) 在C(https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:247444)”
那么,有它的任何溶液或它是在API中另一个错误?
注意:我正在使用office.js API的1.4 beta版本。
你可以使用发布的api版本吗? –