Excel.binding: delete method doesn't actually work

Excel.binding: delete method doesn't actually work
0

Upvotes

Upvote

 Feb 16 2023
0 Comments 
New

Given the below code snippet, I'd expect to get a single console log the first time A1 is updated. Instead I get one every time A1 is updated, indicating that the binding isn't actually being deleted.

 

Excel.run(async (context) => {
  const address = 'A1';
  const bindindId = `myPrefix.${address}`;
  const binding = context.workbook.bindings.add(address, Excel.BindingType.range, bindindId);
  binding.onDataChanged.add(async (args) => {
    console.log('binding onDataChanged', address);
    args.binding.delete();
  });
});

 

 

I also found this StackOverflow question from 2019 outlining the same issue, however their workaround of making the binding id unique apparently no longer works.

 

The documentation for this method (along with the method signature) indicates this should be working.