0

I would like to confirm user before closing a workbook, that is has draft changes. Is there any way to check if workbook is dirty and has to be saved in order not to lose any data?

Vladimir Sachek
  • 1,126
  • 1
  • 7
  • 20

2 Answers2

2

The IWorkbook.IsModified property will flip to true when you make a change to a workbook (either programmatically or through the UI).

Note that any formula updates will not affect this property. So for instance, hitting F9 in the WorkbookView or calling IWorkbookSet.Calculate() to update volatile formulas like RAND or NOW will not mark the workbook as being modified). If you need to keep track of recalculation changes as well, you could handle the IWorkbookSet.EndCalculate() or WorkbookView.Calculate() events.

Tim Andersen
  • 3,014
  • 1
  • 15
  • 11
0

I found out, that the IWorkbook.IsModified property does not flip to true, if changes made to a cell are not confirmed by hitting return or selecting another cell. So how would I find out that changes have been made, when the user closes the workbook?

I found the solution myself in the mean time. And in my case it's quite simple. I just added a handler for the Form.Closing event and added the following line: workbookView.ActiveCell.Activate ();

This makes the IWorkbook.IsModified property flip to true.