5

I'm working on Office 365 Word Add-in that opens a document.

When we open the document via context.application.createDocument(base64string).open(), it launches a new window instead of opening the document in current browser tab (in case of web Add-in) or current instance of word (in case of windows Add-in).

Here is my use case:

  1. Check if there is already an open document and ask the user to save or lose changes.

  2. Have an API to close the current open document e.g. context.document.close();

  3. Open a new document via context.application.createDocument(base64string).open(), so that the document is opened in the current window instead of opening in a new instance of word.

Is there any workaround to achieve this?

Cross posted here.

Thanks.

Baig
  • 1,489
  • 1
  • 25
  • 41
  • 1
    There is a workaround to open the document directly in the body of current document by replacing the current document (context.document.body.insertFileFromBase64(base64string, Word.InsertLocation.replace);), but it doesn't include headers, footers and sometimes the formatting is totally messed up. – Baig May 29 '20 at 14:26
  • Excellent! It's a great workaround! :):):) – Richard Housham Feb 06 '23 at 16:14

0 Answers0