Search code examples
c#excel-dna

How to add handlers to Excel Calculate Events with ExcelDNA


I would like to be able to listen to the BeginCalculate and EndCalculate events for all sheets in Excel from my ExcelDNA addin, and execute some intialization code. Is there a way to do this?


Solution

  • There was some discussion on the Excel-DNA Google group here: https://groups.google.com/group/exceldna/browse_frm/thread/58da470968d6658b This shows how to handle the C API ON.RECALC event, which fires after a recalculation.

    You can get also hold of the Excel Application COM object with a call to ExcelDnaUtil.Application, and then register your event handlers for the Application events. The Application events are documented here: http://msdn.microsoft.com/en-us/library/office/jj734018.aspx and you might be interested in AfterCalculate.

    I don't know of any Excel events that fire before recalculation.