Reputation: 124
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.
Is this normal, or should there be a code to end this function?
Thanks
Upvotes: 0
Views: 73
Reputation: 9659
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.
Upvotes: 1