I am developing an add-in for word. I am trying to replace a bookmark with a text. (My initial target was to insert text in the bookmark but there is a bug in the API so this is the alternate approach. Earlier question link)
Here is my code:
Word.run(function (context) {
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);
But it throws exception. The error trace message is:
"GeneralException: GeneralException at Anonymous function (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:211625) at ai (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:248841) at ft (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:248928) at d (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:248748) at c (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:247444)"
So is there any solution for it or it is another bug in the API ?
Note: I am using 1.4 beta version of the office.js API.