0

I have an Excel Add-in using shared runtme which has some ribbon buttons and one of the ribbon button is used to open a dialog. However if user clicks this button frequantly, I am getting this error ""An internal error has occurred." and no page is loaded in dialog. Even right click on dialog does not show context menu which is usually shown when page is loaded. First image shows empty dialog opened.

enter image description here

Second Image shows debug breakpoint hit and error message I got in host taskpane. asyncResult.error.code has value "-2147467259". enter image description here

Any idea how to avoid this situation?

EDIT: code in ribbon event handler:

if(dialog)dialog.close();// close previously opened dialog. here dialog is reference of previously opened dialog if any
Office.context.ui.displayDialogAsync(urlp,
        { height: height, width: width, displayInIframe: true }, dialogCallbackIFrame);

event.completed();
2
  • What code do you have in the ribbon button's event handler? Did you try to just display a dialog box without any additional code? Commented Feb 10, 2023 at 22:54
  • @EugeneAstafiev I have updated question with code in ribbon event handler. Commented Feb 14, 2023 at 19:19

1 Answer 1

1

You need to wait a bit until the previous dialog is closed. Try to add some delay before calling the displayDialogAsync method.

Sign up to request clarification or add additional context in comments.

3 Comments

I will try to add a delay, however as per documentation there is no way to know how much delay should be added and if previous dialog is not closed and next dialog open call will send 12007 error, in this case I called Open dialog function again as shown in 2nd image in question. and this approach is working if user does not click ribbon button so fast.
True, but I've found that increasing the delay between attempts may help.
even though delay has not eliminated problem, but it has significantly reduced its occurrences.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.