I have created a taskpane addin for word that is using the Document.getFileAsync method to get the document contents in Compressed format (docx). This works correctly for .docx files, but unsurprisingly fails if an old .doc file is used.
I get the following error:
code: 5001
message: "An internal error has occurred."
name: "Internal Error"
Is there a way to detect documents in invalid formats before calling getFileAsync? I have tried reading the document properties format value using the following code:
return Word.run(function (context) {
var properties = context.document.properties;
context.load(properties, "format");
return context.sync()
.then(function () {
return properties.format;
});
});
But the returned value is always an empty string for both docx and doc files.
I would like to be able to detect old file formats so that I can display an appropriate error message to the users.