Office Web Addin - Open or save or load document from specfic location - ms-word

I'm working on an Office word web add-in (not VSTO). I have opened a new / existing document from the current system or from a Sharepoint document library and side-loaded my taskpane addin and ribbon menu. Using a ribbon menu control, I should open a document from a sharepoint document library for editing and saving to some other location in Sharepoint. Is it possible in office.js?
Shall I open the document using Javascript API (office.js)?
If Point 1 is possible then can I open document from Sharepoint or one drive?
Can I save document using office.js to specific location?

Did you tried:
using the graph API to access the files you need out of One Drive.
use the context.application.createDocument().open() API to open the file in Word.
Finally, after user updates, use the getFileAsync() method to get the base64 encoded docx and upload it back to one drive or wherever you need to?

Related

Update docvariable or docproperty in Word online

Is ther a way to update docvariable or docproperty of a Word document when opening in the Word online by the microsoft graph API or another API.
I do this in Word for desktop using C# code, but I need to do this in Word online too.
It can't be done in Word on-line. If you had an Office JS add-in you might be able to change document properties (but no DocProperty fields that reflect those values). The Word JS APIs do not access the Document Variables, however.
But you should be able to do it on the closed file (before it's opened in Word on-line, for example) by leveraging the Word Open XML file format. There are numerous libraries to work with it. Microsoft's is the Open XML SDK (free, as a .NET Framework / Visual Studio extension) which can access all content of Office files (except VBA binaries).

Word Add-in - Save/load document to/from a specific location

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?
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

Dynamic data manipulation in word online

I am trying to build a task-pane add-in for word online which can do mail merge like desktop office. Now I understand that word online does not support mail merge out of the box, so I thought about the following steps -
Create a template (DOTX) using desktop office which will contain Region or something like a merge field etc. Upload the template to one drive.
Open a blank doc and add a task pane add-in in word online. This is temporary step for now.
Click a button on the add-in.
This click will stream the template (DOTX) from server using an app service call.
Render the stream into word online web page.
Edit and save.
Close word online and reopen.
Click the doc link.
This will render the doc in word online.
Add the add-in in the task pane (temp step).
Click edit button.
Call app service to fetch the latest merge data source.
Traverse through the word xml and replace the values corresponding to the region or special keys.
Re-render the doc.
My users will have E1 subscription of office 365.
Is this thought process logical and achievable with word online? Thanks in advance!...
I think your approach is much more complicated than it needs to be. Word Online supports Add-ins created using the JavaScript APIs, as supported by the information in this article: https://msdn.microsoft.com/EN-US/library/office/dn833104.aspx
It should be possible for you to create the "template" on the Desktop (Word 2013 or 2016 is required - but only 2016 supports the current full scope of the JS API) and "insert" your add-in, which links it to the document. Opening the document in Word online should automatically load the add-in, that can then link to the data source and fill in the data.
As data targets ("merge fields"), I recommend you use Content Controls.

Saving document to server in Java

We have an existing web application written in Java. We want to give our users the ability to open a Word document that is stored in our application on the server. So when the user downloads the document from our server, Word pops up and they then can edit this document on the client. Once finished editing the document we would like to give them the ability to save this document automatically back to the server where they retrieved it, by simply selecting on the Word Save icon. Similar to how SharePoint does it.
Seems to me SharePoint would be a good solution for this and they do it very well, but unfortunately we cannot use SharePoint in our architecture.
There also seems to be a lot of server-side possibilities that we can use to upload and open word documents from our server, I feel we can solve these use cases easily.
My big problem is the automatic saving of an edited document by the client back to our server where the document was downloaded
I am not Microsoft proficient to know what the best solution would be.
Should we write a Word AddIn to save to our server?
How do we get the Word AddIn into our users desktops?
Can we embed a Word AddIn into the Word document that is opened on the client?
1.Should we write a Word AddIn to save to our server?
If you don't want to use SharePoint you can develop an add-in where you can implement all the required functionality and much more.
2.How do we get the Word AddIn into our users desktops?
You can develop an installer for the add-in. See Deploying an Office Solution for more information. Also you can use the group policy objects for deploying the software automatically.
3.Can we embed a Word AddIn into the Word document that is opened on the client?
You can develop a document-level add-in, i.e. the code will be run for a specific document only. But you will need to install it as an application level add-in. See Architecture of Document-Level Customizations for more information.

Dropbox API integration with Microsoft Mail Merge

I am trying to pass values to be shown in fields inserted in Microsoft Word documents or be an overlay (what is the correct word). Can it be done?
You can't selectively modify portions of a file on Dropbox remotely using the API, if that's what you mean. The API only allows you to upload new entire new versions. So you can download the file, modify it as desired, and upload the new version