ms-wordoffice-jsoffice-addinsword-addinsword-web-addins

Word addin, set filename


If one starts a blank file on Word you can usually see in the top bar a name such as "Document1", "Document2" and so on.

Yet, if you attempt to open a file using the Word JS API like this:

Word.run((context) => {
  context.application.createDocument(documentB64).open()
  return context.sync()
})

The top bar comes out like this:

enter image description here

No filename is set.

To set a filename/handle(?), I tried using the code given here Office JS - Add customProperty to new document but that didn't help.

My addin is usually used in conjunction with another (VSTO) add-on and that add-on can't work properly with the documents opened by my addin and I believe the lack of a filename (/handle?) explains it to some extent.

Is there something I can do about this?

Thank you


Solution

  • Workaround:

    If you're downloading the file from the Internet you can use an Office URI instead, which resolves the problem.

    https://learn.microsoft.com/en-us/office/client-developer/office-uri-schemes