0
votes

I'm currently developing a Word add-in using the word-15.js script. I'm trying to save the document on some location. I assume that calling document.save(), saves the document to a location where the document already exists, so only if the document has been saved before and isn't a new document.

In my scenario, I'm trying to save/load a new document. For instance, when the user has created a new document and entered some text or other data, my add-in can load a SharePoint document library and save the that location. For instance: https://my-tenant.sharepoint.com/sites/my-site/_api/web/GetFolderByServerRelativeUrl('Shared Documents')/Files/add(url='test.docx', overwrite=true).

I haven't seen this done in any examples that I've been able to scramble through. Is this even possible? And if so, how?

1

1 Answers

1
votes

there is no such API. you can, however, get the document (as docx, pdf or txt) using the getFileAsync API. and then once once you have the bits of the document you can upload it anywhere you need.

Here are more details and an example on how to use getFileAsync. https://github.com/OfficeDev/office-js-docs/blob/master/reference/shared/document.getfileasync.md