How to tell if Excel workbook has been closed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a VB.net assembly that manipulates excel data. At the end of data
processing, the user has the option to view the spreadsheet, which is at that
time open and not visible. So at this point it's a simple matter of saying
ObjXL.Visible, which works. However, I need to also test to see if the user
has viewed the workbook already and closed it, and then needs to open it
again. My code should test for the state of the Excel.Application as follows:

If ObjXL is still open then
ObjXL.Visible
Else
Re-open workbook using the last path saved
End if

Problem is, I have searched but cannot find a way to test if Excel is
running and, if not, to reload the workbook. I tried Is Nothing but if the
user closes Excel the ObjXL reference is never set to Nothing and persists.
 
Nevermind-- answered my own question again!

I check to see if the ObjXL.workbooks.count = 0, and if so, I reload the
workbook. Problem solved!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top