0
votes

I have a word add-in which fetches an external document, and then opens the base64 encoded string of the new document. However, currently the new document is opened in a new instance/tab of word. The document is opened with the title - Compatibility Mode.

Instead, I want the document to open in the current instance of word. i.e. saving and closing the current document and opening the new document, meaning that 1 instance of word is only ever open.

After I have retrieved the base64 encoded document from the server, I then perform the following to open the document:

Word.run(function (context) {
    // Create a new document from the base64 string
    context.application.createDocument(base64_document).open();
    return context.sync();

}).catch(function (myError) {
    throw myError.message;
});

How can I ensure that this document is opened in the current Word window?

1

1 Answers

0
votes

I'm afraid that this isn't possible with the current system. An add-in cannot stay alive in a continuous session when the document is closed. This can't be done in the UI or programmatically. When the current document is closed, any add-ins that were running in it close too.