470,602 Members | 1,649 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,602 developers. It's quick & easy.

Close Excel and Detecting Excel Close counterintuitive...

I'm trying to automate some very simple things in excel, but have run into a roadblock (using c++). To detect excel closing, I just monitor the Excel Process using WaitForSingleObject. In order to close it myself, I just call ExcelApp.Quit(). Really basic stuff. Only problem is - I need to release all dispatches to detect the Excel process closing, but I need those dispatches (at least the application one) in order to close excel myself. Am I missing something? It seems like I can have only one or the other. Also, I am opening multiple instances of Excel, so I can't just use GetActiveObject. Is there something I'm missing or some piece of vital information I need? Maybe I'm completely ignorant towards the way this all works and don't realize it? How can I detect the process closing (or any method to detect excel is exiting) as well as always having a way to interface with that instance of excel? Thanks

Cheers
-Scott
Sep 25 '07 #1
1 2512
Im a bit rusty when it comes to COM programming, but you can take advantage of COM Events so a COM application can let you know when things happen.

Excel has a "BeforeClose" event in the Application object, you might want to take a look into it, hopefully it is what you need.

As far as I remember you need to implement IConnectionPoint inside a C++ class to be able to subscribe to a COM event.
Sep 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

14 posts views Thread by IanW | last post: by
2 posts views Thread by Lorenzo Melato | last post: by
5 posts views Thread by Richie | last post: by
3 posts views Thread by David Berman | last post: by
1 post views Thread by Fred Morrison | last post: by
3 posts views Thread by Michael Kellogg | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.