Exceljs App "is working on your function" message

107 Views Asked by At

I modified an Excel ScriptLab function to remove duplicates and I run it as a button from the Ribbon.

async function RemoveDuplicates() {
  await Excel.run(async (context) => {    
    const sheet = context.workbook.worksheets.getActiveWorksheet();
    var selectedRange = context.workbook.getSelectedRange();
    var firstCell = selectedRange.getCell(0, 0);
    var surroundingRegion = selectedRange.getSurroundingRegion();

    firstCell.load('columnIndex');
    surroundingRegion.load('address');

    await context.sync();
    var columnIndex = firstCell.columnIndex;
    
    const deleteResult = surroundingRegion.removeDuplicates([columnIndex], true);
    deleteResult.load();
  });
}

It works well. It finished in a fraction of the second, but I noticed that this, and any other function I have, displays in the bottom-right corner a message that stays there until I run another function. And then the message from the next function stays there.

enter image description here

Is this normal, or should there be a code to end this function?

Thanks

1

There are 1 best solutions below

3
Rick Kirkham On BEST ANSWER

You might need to pass an Office.AddinCommands.Event parameter to removeDuplicates and then call event.completed() at the end of the function. For an example, see Create add-in commands and FunctionFile.