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

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

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.

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?

Custom Ribbon tab missing in Excel

I tried searching for this question but couldn't really find a similar problem.
I have an excel file in which I created a custom ribbon tab and made copies of this file.
Image of the tab
In some of those copies, the tab has gone missing. I was earlier using Excel 2016 and recently migrated to Microsoft 365 and downloaded the latest version of Office. I am not sure if this is causing the problem since some files do still have the custom ribbon.
Thanks a lot for your help in advance.
Regards
Do you get any UI errors when the tab is missed?
By default, if an add-in attempts to manipulate the Microsoft Office user interface (UI) and fails, no error message is displayed. However, you can configure Microsoft Office applications to display messages for errors that relate to the UI. You can use these messages to help determine why a custom ribbon does not appear, or why a ribbon appears but no controls appear.
To show VSTO Add-in user interface errors you need:
Start the application.
Click the File tab.
Click Options.
In the categories pane, click Advanced.
In the details pane, select Show VSTO Add-in user interface errors, and then click OK.
If you deal with documents with embedded customizations, make sure the protected mode is off when the document is opened. See What is Protected View? for more information.

Office Add-ins: Any way to have one always running?

I have an idea for an Office/PowerPoint Add-in. Most of the ones I've seen (and what is sampled in the documentation) are add-in actions that are triggered by a button click in the ribbon, or triggered by an action the sidebar. However, I need the Add-in to be running from the moment PowerPoint opens.
Is there a way to have a add-in that is running in the background? Listening for events? My idea involves catching when the slide changes - but I need this to happen when the PowerPoint is in Presenter view.
Is this currently possible?

Crm Dynamics Plugin to call a contact

I am new to dynamics crm programming. Therefore I am having difficulties in understanding few basic things. I am trying to write a plug-in that would call a selected contact when a custom menu button is clicked. All I can understand is I have to create a menu button on the ribbon and handle its events however I cannot find how to create a menu button programmatically. I should be able to do this because when our software is installed and configured for a crm server the UI of the crm pages needs to be updated automatically. The flow is like this. Go to contacts, select a contact and when you click the custom menu button (should be available on the ribbon after our product's installation) the option to call home, office or mobile should be presented to the user and then the call should be placed to the contact. How can I achieve this? Is it handling the javascript events or are there any readily available API to handle the ribbon menu items?
The Ribbon is defined in the Ribbon XML of the solution. You can't programmatically create a button on the fly (although you can use javascript to hide/disable it). Try the Ribbon Editor to get your feet wet with the ribbon.
From there you can use javascript on the click of the button to perform whatever functions you need.

Resources