With WordApi 1.3 it should be possible to use the new createDocument method to create new documents from within the web addIns.
However, when using the example snippet below found in the documentation, context.application
is undefined
.
Word.run(function (context) { // lets hold a valid base64 docx on this variable...
var myStartingDocAsBase64 = "some valid base64 encoded docx";
var myNewDoc = context.application.createDocument(myStartingDocAsBase64); // note that the parameter is optional, a blank doc will be created otherwise // at this point you can use the entire API on the myNewDoc document.. you can do things like
myNewDoc.body.insertParagraph("This is a new paragraph added via API", "end"); //now lets open the document, after this method is called, you will no longer be able to modify the doc.....
myNewDoc.open();
return context.sync();
})
.catch(function (e) {
console.log(e.message);
})
This is even though Office.context.requirements.isSetSupported("WordApiDesktop", "1.3")
returns true.
This is tested in Office 1611 on Windows 10 (shown in the image below).
Are the features in 1.3 not fully implemented yet, or should we do something else to get createDocument
to work?