1

I have an excel add-in. I placed two content-pane from my add-in and i would like to open a dialog from it.

One excel allow only one dialog window in same time.

When i open a dialog window before i have an ajax request to server, but if i can not open the dialog window then i no need ajax call.

I tried to save information to localStorage, but if excel is hurm and reload itself, localstorage will show that dialog is open in turn this is wrong information.

How can I check if I have an open dialog window?

Thank you in advance for your answers.

Péter
  • 273
  • 1
  • 10

2 Answers2

2

The displayDialogAsyc method will return error 12007 if there's already a dialog open. You can test for this and have your code branch if 12007 is returned. For some details, see Errors from displayDialogAsync.

Rick Kirkham
  • 9,038
  • 1
  • 14
  • 32
  • I understand your solution, but my code look like this: 1: ajax call 2: when response recieve from ajax -> dialog open. My problem: i should not create ajax call if i can not open dialog window – Péter Mar 28 '20 at 19:12
  • in office for Windows and mac you don't get 12007, and it is possible to open multiple dialogs but when you close the dialog you get 12006 error. – yossico Mar 14 '22 at 09:58
1

I found a solution, but i think it is not the best.

Firstly i try to open a dialog with a not trusted site url.

If i get 12004 error it means i can open a dialog window.

If i get 12007 error it means i can not open dialog window beacuse already opened a dialog from this host window.

It seems like 12007 check is runs earlier than the 12004 check.

Péter
  • 273
  • 1
  • 10