View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default How to close ALL instances of Excel

Sorry, that should be PostMessage not SendMessage.
http://support.microsoft.com/?kbid=176391
http://vb-helper.com/howto_terminate_process.html

But you would still need to check if the Excel instance is yours, if running
in Excel/VBA.

NickHK

"NickHK" wrote in message
...
This code is to run in Excel VBA ?
You want to close your own instance ?

Depending on the above GetObject may not be the answer, as you cannot
stipulate which instance gets returned.
Maybe use the API FindWindow with "XLMAIN" and SendMesssage with

"WM_CLOSE"
?

NickHK

"spIky haIred" wrote in message
oups.com...
Hi everyone,

I would like to close ALL instances of Excel... I am able to close all
workbooks within an instance of Excel but cannot close workbooks in
other instances of Excel... Is there a way to scan all open windows? Or
even better, to scan all open instances of Excel only?

Help would be much appreciated.
Thanks in advance,
Jason