ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close all Instances of Excel (https://www.excelbanter.com/excel-programming/323522-close-all-instances-excel.html)

tod

Close all Instances of Excel
 
I guess this is more of a vbscript question, but what
would be the best code to close all open instances of
Excel?

AA2e72E

Close all Instances of Excel
 
This script will close all instances of Excel and will NOT save any changes
made to the active workbookof each session: type the code in a file with
extension VBS, locate it in Explorer & double click.

CloseExcel
SUB CloseExcel()
on error resume next
set xl =getobject(,"Excel.Application")
xl.activeworkbook.saved = true
xl.Quit
set xl = nothing
call CloseExcel
End Sub

"Tod" wrote:

I guess this is more of a vbscript question, but what
would be the best code to close all open instances of
Excel?


tod

Close all Instances of Excel
 
This script works great for instances that are open and visible. Is
there a way to close all instances that are only onen in memory?


AA2e72E wrote:
This script will close all instances of Excel and will NOT save any

changes
made to the active workbookof each session: type the code in a file

with
extension VBS, locate it in Explorer & double click.

CloseExcel
SUB CloseExcel()
on error resume next
set xl =getobject(,"Excel.Application")
xl.activeworkbook.saved = true
xl.Quit
set xl = nothing
call CloseExcel
End Sub

"Tod" wrote:

I guess this is more of a vbscript question, but what
would be the best code to close all open instances of
Excel?



Tom Ogilvy

Close all Instances of Excel
 
Were these created through code?

If so, it sounds like your code is faulty as they shouldn't exist. You
won't be able to close them through automation - they are being held open by
an unreleased reference. Until the reference is released (or overpowered),
then they will remain.

--
Regards,
Tom Ogilvy

"Tod" wrote in message
oups.com...
This script works great for instances that are open and visible. Is
there a way to close all instances that are only onen in memory?


AA2e72E wrote:
This script will close all instances of Excel and will NOT save any

changes
made to the active workbookof each session: type the code in a file

with
extension VBS, locate it in Explorer & double click.

CloseExcel
SUB CloseExcel()
on error resume next
set xl =getobject(,"Excel.Application")
xl.activeworkbook.saved = true
xl.Quit
set xl = nothing
call CloseExcel
End Sub

"Tod" wrote:

I guess this is more of a vbscript question, but what
would be the best code to close all open instances of
Excel?





tod

Close all Instances of Excel
 
Okay. Actually there are a few dozen excel applications being open (not
all at once of course) and updated through scheduled tasks. I didn't
write them, but am having to contend with the mess that many of them
leave behind. I'm fixing the code in them as I go, but was hoping for
an interim way of closing these open instance of Excel before they
totally hose the memory on the server.


tod

Close all Instances of Excel
 
Oh also, would there at least be some kind of code I could use to get
information about an open instance of Excel? What workbook is open,
etc?


Tod wrote:
Okay. Actually there are a few dozen excel applications being open

(not
all at once of course) and updated through scheduled tasks. I didn't
write them, but am having to contend with the mess that many of them
leave behind. I'm fixing the code in them as I go, but was hoping for
an interim way of closing these open instance of Excel before they
totally hose the memory on the server.



Tom Ogilvy

Close all Instances of Excel
 
Perhaps you can start with this:

http://support.microsoft.com/default...b;en-us;176391
How To Programmatically Close a Single Instance of a Windows-Based Program

I expect that you will have to use the terminateprocess function it
describes and says to use with caution. But I don't know. Then again,
these processes may not have windows (but I think they would).

This may have some useful information although not directly applicable:
http://support.microsoft.com/default...b;en-us;231844
How To Detect If an Application Has Stopped Responding



--
Regards,
Tom Ogilvy


"Tod" wrote in message
oups.com...
Okay. Actually there are a few dozen excel applications being open (not
all at once of course) and updated through scheduled tasks. I didn't
write them, but am having to contend with the mess that many of them
leave behind. I'm fixing the code in them as I go, but was hoping for
an interim way of closing these open instance of Excel before they
totally hose the memory on the server.




Tom Ogilvy

Close all Instances of Excel
 
maybe by reading the caption of the childwindow if it has any. Since these
sound like partially closed versions of excel, I am not sure what you can do
with them. If GetObject doesn't find them, I am not sure how useable they
are.

This certainly isn't something I am an expert on, so someone else may have a
better idea.

--
Regards,
Tom Ogilvy

"Tod" wrote in message
ups.com...
Oh also, would there at least be some kind of code I could use to get
information about an open instance of Excel? What workbook is open,
etc?


Tod wrote:
Okay. Actually there are a few dozen excel applications being open

(not
all at once of course) and updated through scheduled tasks. I didn't
write them, but am having to contend with the mess that many of them
leave behind. I'm fixing the code in them as I go, but was hoping for
an interim way of closing these open instance of Excel before they
totally hose the memory on the server.






All times are GMT +1. The time now is 11:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com