Detecting if Excel file has been closed

Posted by Charlie on Stack Overflow See other posts from Stack Overflow or by Charlie
Published on 2010-05-01T00:41:43Z Indexed on 2010/05/01 0:47 UTC
Read the original article Hit count: 288

Filed under:
|

Hi StackOverflow, I've spent the past 3 hours trawling the web for answers to no avail, so I hope you can help me. I'm writing an application which automates Excel. The application has an option to "show/hide the excel sheet" so you can look at it, make any final changes and so forth.

Closing the application will naturally close the instance of Excel, however, there is a small chance that someone may exit out of Excel directly, without thinking. This breaks my application and I can't seem to find anyway of "checking if the same workbook is still open, and if not, re-opening it", before saving it

I've tried all sorts of things: checking if the Excel Application is null (when it's !=null it will save correctly, but when it "is" null (or at least, something other than !=null it won't even hit the breakpoint so I'm completely lost :(

Help please?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET