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

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?

Related

How to show prompt alert box in Excel add-ins using Office Js?

I'm new to office js. Just I need to show prompt alert box using office Js but Javascript alert not working inside office js. Can someone help me to do this?
Expected alert box
You can use the Office dialog API to open dialog boxes in your Office Add-in.
To open a dialog box, your code, typically a page in a task pane, calls the displayDialogAsync method and passes to it the URL of the resource that you want to open. The page on which this method is called is known as the "host page". For example, if you call this method in script on index.html in a task pane, then index.html is the host page of the dialog box that the method opens.
The resource that is opened in the dialog box is usually a page, but it can be a controller method in an MVC application, a route, a web service method, or any other resource. The page or website refers to the resource in the dialog box. The following code is a simple example:
Office.context.ui.displayDialogAsync('https://yourAddinDomain/yourDialog.html');
Read more about that in the Use the Office dialog API in Office Add-ins article.

Excel web add-in: How to detect ribbon click events?

I am working with the Excel JavaScript API and I am trying to trigger an event when the user clicks on any ribbon button or tab, and get which button or tab was clicked, but I couldn't find a way to do it.
Can anyone help me?
This isn't a supported scenario in Office.js. Your add-in is running in a sandboxed environment (either within an IFRAME or an embedded browser, depending on the platform). Even in cases where the ribbon buttons are part of your add-in, the communication is one-way (clicking the button will trigger loading a page or firing a function from your add-in).

Outlook Addin window.open

I´m new to the addins, just want to perform a simple task as creating a button with a link in the taskbar that opens a browser and that´s it.
So far created the project based on ms tutorial and everything is working great (with fixed certificate problems).
To my understand this should be as easy as to create a button with an ExecuteFuncion actions mapping to a javascript function with a window.open
e.g.
function windowOpen(event)
{
window.open("https://www.microsoft.com");
event.completed();
}
Thanks for the help,
Regards,
André
For security reasons, Outlook does not support window.open directly inside of Add-ins. To open a window in an Outlook Add-in you can use the displayDialogAsync API (documentation here.) We recommend this guide to understand end-to-end usage of displaying a dialog in an Add-in.

window.opener does not work in Excel for Windows

I have built an Excel add-in, it opens a popup by window.open, then the add-in communicates with the popup site. I just realised that it does NOT work in Excel for Windows, the reason is that the popup can NOT get the host by $window.opener.
To illustrate this and avoid cross-domain, I have made a xml, which refers to the add-in and the test page. It works well in Excel Online in Chrome and in IE. However, while running it in Excel for Windows, $window.opener returns undefined.
Could anyone tell me what happened, and what's the workaround?
(for people who recommend Dialog API, please see this thread. So now neither Dialog nor window.open works in Excel for Windows).
UI.messageParent also won't work? It's from the official docs.
Example:
Office.context.ui.messageParent("Message from Dialog box")
Docs:
Delivers a message from the dialog box to its parent/opener page. The page calling this API must be on the same domain as the parent.
(I assume this isn't the Dialog API which you referring)

Open an html page in a default browser from an add-in

I would like to insert a hyperlink to the task pane of my add-in, and I want this link to open support.html page in a default browser.
Support
However, the above code opens support.html page inside the task pane. Users may not know how to go back to the main page of the add-in.
Does anyone know how to open the page in a default browser of users? (By the way, is it recommended to launch something outside the add-in? If not, what's the common UX design for the help page?)
You can open a new browser window from an Office Add-in via JavaScript: simply
window.open("your-url.com");
Alternatively, if you want the browsing experience to be more in-line, you can use the dialog API:
Office.context.ui.displayDialogAsync(url,
{ height: 75, width: 80, requireHTTPS: true });
See https://github.com/OfficeDev/Office-Add-in-UX-Design-Patterns-Code/tree/master/templates/feedback/office-store for a full example.
~ Michael Zlatkovsky, Developer on Office Extensibility Team, MSFT
If you are trying to open the default OS Browser use the following:
Office.context.ui.openBrowserWindow('https://someurl.com')
This launches the default browser instead of a Dialog box attached to the Addin
https://learn.microsoft.com/en-us/javascript/api/office/office.ui?view=excel-js-preview#openBrowserWindow_url_

Resources