The Context
Currently I am developing a Word add-in that uses the new Javascript API's for Office. The add-in consists of some basic functionalities and a number templates. One of the wishes from the client is to open the templates from the ribbon. Currently I have a command add-in dropdown, where each dropdown menu item refers to a function in the functions file of the add-in. These functions in turn call some Word Javascript API methods, that read and open a base64 string from a .docx file.
The Problem
Simple files are opened without any problems, however more complicated files that contain images, content controls, etc fail. The more complicated files raise a 'GeneralException'. The author of this issue states that it has to do with images that are contained within the document. However this does not align with my personal experience. Images can be added, and the document is still opened. So I assume some other part of the document might trigger problems, however I am not sure!
Therefore I was wondering whether someone is able to shed some more light on this problem.
Code
Word.run(function(context) {
let letterTemplate = context.application.createDocument(<base64string>);
letterTemplate.open();
return context.sync().then(function () {
console.log("success");
})
.catch(function (error) {
console.log(error);
})
});
Any help, tips or advice are welcome.
EDIT: Problem Identified
After some experimentation, I concluded the following. Whenever a (in this case rich text) content control is added to the header in a document, it cannot be opened with the method context.application.createDocument. Trying to do this will result in a 'GeneralException', which does give any specific information. My suspicion is that this is a bug in the Office Javascript API.