I've created an Excel add-in using Yeoman and it has taskpane and Custom functions. For my custom functions I use a dialog box using displayDialogAsync method to open the dialog box and display a list of data which user can select and that selected value is then sent to Excel using messageParent. where It takes the value for example - "Hello" is the value selected and sent from Dialog box and displayed in the cell where Excel Custom Functions was invoked.
This works perfectly fine on Excel web but on Excel desktop it shows the dialog box and when the user selects the value it's not displayed back in Excel Desktop application.
Here is my code for using the displayDialogAsync and saving the value in Excel -
var dialog;
//invoc is the cell address where the custom function is called
// arrLocalStorage is some data sent through query parameters which are displayed on dialog box
Office.context.ui.displayDialogAsync(
`https://azure-storage-container-url.net/dialog.html?arrToSend=${arrLocalStorage}`,
{ height: 50, width: 50, displayInIframe: true },
function (asyncResult) {
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, (arg) => {
dialog.close();
let msgFromDialog = arg.message;
Excel.run(async (context) => {
var ws = context.workbook.worksheets.getActiveWorksheet();
var range = ws.getRange(invoc);//invoc is cell address where custom function is called
range.values = [[msgFromDialog]];
await context.sync();
});
});
}
);
I've tried to look at why this was causing issue but on excel desktop I can only find this in the console of the page of the dialog box -
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'register') excel-win32-16.01.js
.
Does anyone know what can be done to get this working?