Reputation: 321
I'm working on developing an add-in for Microsoft Word using the office-js library. Everything is working as expected in the Mac Desktop version of Word (Office 365). When I use the same add-in on the Online version of Word though, it fails.
The particular problem I'm running into is with inserting a ContentControl. In Word Online, the ContentControl isn't inserted, and all the commands after attempting to insert are not reflected in the document, but there's no error thrown and execution continues as if everything ran fine.
I've made a simple reproduction of the issue in this github project - https://github.com/lightman76/word-addin-online-problem1
All the non-boilerplate code for that run process is in src/index.js
Am I misusing the API in a way that just happens to work in desktop Word, or is there an issue with the Online version of Word?
Upvotes: 1
Views: 187
Reputation: 26
I tried your code on Word Online and found two issues: 1. Cannot insert content control. 2. Cannot change the place holder text of the context control.
For #1, you can update the code as below to make it works on all platforms.
...
var pageTitleParagraph = endOfBodyRange.insertParagraph('Works Cited', Word.InsertLocation.after);
pageTitleParagraph.alignment = Word.Alignment.centered;
// ++++++++Insert an empty paragraph at end of the document+++++++++
endOfBodyRange = doc.body.getRange(Word.RangeLocation.end);
var emptyParagraph = endOfBodyRange.insertParagraph('', Word.InsertLocation.after);
var bibRange = pageTitleParagraph.getRange(Word.RangeLocation.after);
var bibContentControl = bibRange.insertContentControl();
...
For #2, I got below error. It should be a limitation on Word Online.
message: "The action isn’t supported in Word Online. Check the OfficeExtension.Error.debugInfo for more information."
Upvotes: 1