In my add-in, there are some dialogs that opened from the ribbon button (i.e. login and status).
I don't want to allow the user to open more than one dialog at a time.
When using the adding from Office for Web everything is working OK since Office for Web makes the dialog appear as a modal dialog so the user can't click the ribbon to open another one.
But when Office 365 for Windows and Mac the dialog is not modal and the user can open multiple dialogs.
I tried to create a flag in the commands.js (to tell if a window is open) file but it's not working, after a bit of investigation (on mac: defaults write com.microsoft.Excel OfficeWebAddinDeveloperExtras -bool true ) it seems like every time the user clicks the dialog button another commands window is opened so we can't store the context of if a window is open or not.
I saw this solution - to put the flag on local storage: Open only one dialog from ribbon
but the problem with this solution is that if the user exit Excel while the dialog is open (or any other unexpected scenario such as process killed or power down) next time the user will start Excel the user won't be able to open the dialog (the localStorage value will indicate that the dialog is still open).
My question(s):
Is there a robust way to prevent the user from opening multiple dialogs from the ribbon in office 365? How can I safely reset the localStorage value after a crash?
Am I missing something? Can one open the dialog in a modal manner (like in Excel for Web)?
Related
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.
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.
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).
I take Excel for example. At the moment, every time when a user wants to use an add-in, they need to go to insert ==> add-ins and choose the add-in. Then either a take pane or content add-in appears. If the manifest xml of the add-in has add-in commands, users can launch the add-in via menu or ribbon.
If the user des-actives the task pane, closes and re-open Excel, they need to go to insert ==> add-ins again and so on... It is tedious.
Is it possible to set an add-in loaded by default (either by developers or users)? For example, each time the user opens Excel, they could see the item in the menu or ribbon (or even the task pane activated) to launch the add-in.
Unfortunately users have to always manually activate the add-in, either from a Ribbon command or from the Add-ins button. Only COM add-ins allow you to display a Task Pane when the Office application opens.
While the ribbon-button feature mentioned by SoftTimur and Eric is one solution to the problem, another potential solution (depending on your business model) may be to use a template:
You can create a .xlsx document and insert your add-in task pane manually, then share that document with others, who will automatically see the open task pane when they open that document. One strategy is to post this template document online and provide links to it elsewhere.
I work on an Excel add-in product that contains a task pane that has multiple User Controls on it. We have moved our login process from a modal UserForms dialog to a WebBrowser control that is displayed within the Task Pane when the user clicks our Login ribbon button.
The desired behavior flow would be:
user clicks a Login button on the Ribbon - the Login control is shown in Task Pane
until there is a result of login (login succeeded, login failed, or user cancels login), the user could not use excel as though a modal login dialog is being displayed
Once logged in or login is cancelled, user can use Excel again.
In other words, I want the Task Pane control to work like a modal dialog.
I have the login control working great, however I do not know a way to have it simulate being modal. Once the user clicks the Login button, they are free to continue working in Excel, which we do not want.
I have been pondering some ugly solutions like trying to prevent each window within Excel from redrawing using WM_SETREDRAW with SendMessage and also tying LockWindowUpdate, but I was really hoping that someone would know a better way to accomplish what I was trying to do.
Btw, this type of functionality will not only be used for the login control or we might just go ahead and put it in a modal dialog. We are also wanting to do the same with a couple of other controls where we want the user to have to use the control before we allow them to continue in Excel.