How to open a file location in my PC using javascript for Apps for office 2013? - apps-for-office

I have created an Task pane app for office 2013 in excel. It has few buttons and labels.
Now I want to open a file location on my PC on clicking of the button. So please tell me the code for it as I'm new to java-script.

As far as I know, there is no existing openFile API in JavaScript for Office, but you can use ajax to call wcf to get string from existing document and use Document.setSelectedDataAsync method to write the got string to the document.

Related

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

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).

Office Scripts Open Excel file in Desktop

Dears,
In Excel webapp, there is a menu button to open the Excel file in desktop app.
Can this action be done in Office Scripts? Open Excel file in Desktop?
main(workbook: ExcelScript.Workbook) {}
I answered the question here already. But for people landing on this page here it is.
See Office URI Schemes
To open an Excel file you can do something like this:
ms-excel:ofe|u|https://locationofthefile.com/file.xls
Use ofe to open a file and edit or ofv to open a file and view.
There are more complex options as you can read in the docs. But this will probably do it for the most cases
Application
URI
Word
ms-word:
Power Point
ms-powerpoint:
Visio
ms-visio:
Access
ms-access:
Project
ms-project:
Publisher
ms-publisher:
SharePoint
ms-spd:
Infopath
ms-infopath:

Close open Desktop Taskpane using office.js or Add-in manifest function

We have created add-in manifest xml file for our application and also embed office.js file.
We have use custom ribbon feature by assigning url to icon. When we click on icon, it open task pane on desktop. We want to open third party url in new window of browser using Add-in manifest and taskpane should be close.
We have gone through AppDomains and uses Office.addin.hide function. But both solutions are not working.
Please provide us solution if exist.
Office.js doesn't provide anything for opening a new tab in a web browser. Instead, you can display a popup message. In Excel, you can use the following code to hide the task pane:
Office.addin.hide();
For example:
function onCurrentQuarterDeactivated() {
Office.addin.hide();
}
See Show or hide an Office Add-in in a shared runtime for more information.
You may try to use UI less function, in UI less function, you could execute a javascript code to open a page in the default browser.
You could refer to this answer.
Open directly a web page from a button in Ribbon in a browser outside Excel?

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.

Mimic Sharepoint edit Office file download

When you browse a list of files in Sharepoint using IE and attempt to download the file, you get the option of opening it in read-only or edit mode. When you open the document, Office knows that the file exists in Sharepoint so when you save, it is updated in Sharepoint without the user having to re-upload the file.
I'd like to have this same functionality in a custom website. I have access to Sharepoint and the file list so I'm using the same URL that Sharepoint is to download the file but there's something else happening in Sharepoint that tells the computer to not download a copy of the file but to open it in Office from the Sharepoint URL.
Does anyone know how to mimic this same behavior so I can get a file to be opened in Office from Sharepoint to it can save directly back to Sharepoint?
The special thing about this, is the link:
It's not just http://example.com/document.docx . It's ms-word:ofe|u|http://example.com/document.docx .
Just add ms-word:ofe|u| in front of the link for letting the browser know to open the link with an other Application.
There are other strings for other links.
Open a OneNote-File with:
onenote:http://example.com/document.one
And Excel-Files with
ms-excel:ofv|u|http://example.com/document.xlsx
And just for fun a TeamSpeak Link:
ts3server://example.com
Create URL for MS Office 2010 (and higher) to:
open document in view mode:
ms-excel:ofv|u|http://server.com/path/filename.xlsx
open document in edit mode:
ms-excel:ofe|u|http://server.com/path/filename.xlsx
List of MS Office apps URL scheme names:
ms-word:
ms-powerpoint:
ms-excel:
ms-visio:
ms-access:
ms-project:
ms-publisher:
ms-spd:
ms-infopath:
MS has a good page with explanation:
MS Office Dev Center > Office URI Schemes

Resources