0

Is possible open a remote file (url, xml, binary) ?

For example, I open a dummy docx with Add-In (from url) then the Addin retrieve a xml docx from url and put it in opened document (replace document dummy).

Is possible?

Thanks.

P.S.: I create a Addin and I retrieve a xml docx from url on open dummy file but I fail to put into opened document (replace).

  • The current Office APIs contain no command that allows you to directly insert a file into the current Office application's document. But it would be possible for your Add-in to read that document into memory and insert the content directly. I assume you want to put content from a docx into a docx? You can access the Office Open XML content using, for example, the Open XML SDK or the one for JavaScript, convert the content to the OPC flat-file, then write that OOXML into the open Word document. – Cindy Meister Jan 21 '16 at 18:18

1 Answers1

1

If I understand correctly, you are close to doing what you want. Once you have the docx file, then you need to base64 encode it. Here's a SO post about this. Once it is encoded, then you'll use the insertFileFromBase64 method on the Body object.

bodyObject.clear(); 
bodyObject.insertFileFromBase64(base64docxfile); 

Here's a related example that does the base64 encoding on the service (different than what you want), and then clears the dummy doc and opens the docx file in the client.

Community
  • 1
  • 1
Michael Mainer
  • 3,387
  • 1
  • 13
  • 32