Save Microsoft Document(s) Java script API for desktop add-ins - excel

Web versions for MS Office word, excel, power point documents are saved automatically online(even document name is not saved). Is there any common Java script API available for add-in's to save desktop versions word, excel, power point documents with default file name(without save as)?

Yes, there is. For example, in Excel web add-ins you can use the save(saveBehavior) method where you could pass the save value which allows to save the workbook without prompting the user. If file is not saved, it will save it with default name in the default location.
You can file a new feature request at https://aka.ms/M365dev-suggestions for other Office applications (Excel and PowerPoint).

Related

Office.Settings not retrievable in Excel Online when created and set in Excel Desktop

According to the API docs, the Office.Settings objects are saved per add-in and per document. That is, they are available only to the add-in that created them, and only from the document in which they are saved.
I'm a bit confused regarding the Office.Settings interface. I've created a gist in the ScriptLab Add-in where I set 2 setting objects (queries and queryIDs) and then retrieve them (log them to console).
Gist: https://gist.github.com/VivianVenter/e5489628384f96f2d3bf9a50aace8728
If I run this gist on Excel Desktop, then I can create the settings and retrieve them successfully. If I save this workbook and open it in Excel Online and run the gist again then I cannot retrieve the settings, it returns null for both settings object.
According to my knowledge the ScriptLab Add-in is the same for the Desktop and Online version, am I missing something, or is it the intention of OfficeJS to not make the settings available/visible in the Online version if it was created and set in the Desktop version?
Settings desktop found:
The settings objects was found in Excel Desktop
Settings online null:
The settings objects was NOT found in Excel Online
Office add-in's setting is stored based on the add-in's id.
And once it is installed by side-loading, a new id is allocated to the add-in every time.
This means you can't sync settings on multiple platforms while developing.
Once you submitted the add-in to the AppSource, a static id from AppSource is allocated to the add-in and it is used while installing the add-in from AppSource.
So, you should submit the add-in to AppSource to test/implement this feature.
The issue was caused by a bug in office-js which has now been fixed upstream.

Office JS API: last saved time?

I develop a Javascript Office add-in which can run on Word, Excel and PowerPoint.
One of the features of the add-in is to suggest user to upload current file to our server if the file have changed and/or saved since the last successful upload.
I had some luck with document.properties.lastSaveTime for Word application: https://dev.office.com/reference/add-ins/word/documentproperties?product=word
But this API is Word-specific and is not available for other hosts.
Is there a way to get the date of last file change (document, workbook and presentation accordingly to the host application) using shared API, that is, API available for all three hosts?
If such shared API functionality doesn't exist, even some clue of how to get last changed date of individual hosts' files would be helpful.

Launch an add-in systematically when opening a file

I want to make an Excel Online file, then post its link or embed it in my website. Clicking on that will open the file in Excel Online. Moreover, I want certain Excel add-ins to be installed and even launched automatically.
Does anyone know if it is possible?
If it's impossible with Excel Online, is it possible for a normal .xlsx file (I will make it, and opening it in Windows systematically leads to install an add-in and even launch it)?
If you're looking to automatically open a task pane add-in when the Excel file is opened, check out this article in the documentation: https://dev.office.com/docs/add-ins/design/automatically-open-a-task-pane-with-a-document?product=excel. The Office OOXML EmbedAddin sample provides an example of implementing the autoopen functionality that's described in the article.
Along with Kim's answer to automatic opening of a task pane add-in, you can using OneDrive to handle opening a file in Excel Online using Microsoft Graph.
You're start by uploading you're .xlsx file to OneDrive using an Upload Session. Once you're file is on OneDrive, you can retrieve it's meta-data for the DriveItem. Included in this meta-data will be a webUrl property. This is a URL that, when navigated too, will open your file using Excel Online.

Updating Excel document with macros

Using the Microsoft Graph API with Office 365, I've not been able to update a .xlsm file with macros, even if all I'm changing is a row of data.
If I open the file in the web version of Excel (Office 365) and make an editable copy and re-save
The same command for a .xlsx file is fine.
OneDrive identifies a change has happened as the modified date changes, and the desktop app re-syncs the files.
In the web version, you can create an editable version and then when you download that file to the desktop the macros still exist.
If it isn't possible to normally modify the file, is it possible to emulate this behavior?

Opening documents in the client application from Sharepoint Lists

I have created a couple of sharepoint lists, one that uses a lookup on the document library to link multiple documents to a list item. The other list is to create tiled links that link to documents, again in the document library.
I am using Sharepoint as part of Office 365
The problem I have is that opening the documents from these lists open in the browser instead of the client application (usually Excel), the spreadsheets are too complex for the browser based version of Excel so I need them to always open in the client application.
So far, I have set the default open option for the document library (Documents Settings > Advanced Settings) for the master site and subsite to Open in Client application by default; obviously this works for the document library, but doesn't work for the lists.
Searched for ages on this problem and either nobody has it or people that do this aren't bothered by documents opening in the browser. Would be greatful for any help on this, or if you can think of a better way to do it....
You could export list items to excel file (List ribbon -> Export to excel) and then upload that excel file to some document library.
Then, the users would open the excel file from the library and they would need to refresh the data from excel, by clicking Data ribbon -> Refresh All
That is the closest that you can do with opening list items with excel without any programming.
Please note that users will have to be logged in to SharePoint and have the Read permissions in SharePoint list in order to Refresh the data.

Resources