Is this possible/the best way to do it?

  • Thread starter Thread starter Marek
  • Start date Start date
M

Marek

Hi
From C#, I need to instantiate MS Excel, allowing the user to modify the
workbook/sheets. The C# then has to wait for the user to close Excel down.
First of all, I need to know when this happens.

When I (manually) close down Excel and go back to the debugger, it appears
that Excel is still actually running, but it has been made invisible
(objExcel.Visible = false).

It seems that this may be an unreliable way of achieving what I want.
Ideally I would like to be able to query Excel before it actually shuts
down, but I guess I can always re-open the workbook to get the information I
need (any new/deleted named ranges). What is the best way to achieve this
functionality?

Thanks.

Marek
 
there's no easy way to do this. some time ago, a user in here figured that
s/he could get a list of process id's running on the machine before excel is
loaded and after excel is loaded. The extra pid would normally represent
excel. finally, the code looked for this pid to determine whether excel was
closed or not. You can see holes in the logic but it's probably a good short
term strategy if you can't find a better way to do this.

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
 
Back
Top