Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default 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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default 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?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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?




  #5   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default 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.



  #6   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default 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.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If two instances of Excel open top right "X" close only one [email protected] Excel Discussion (Misc queries) 1 July 16th 08 07:47 PM
why do all excel worksheets/workbooks close when I close one? Penny Excel Discussion (Misc queries) 1 November 29th 06 03:49 AM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
I can't save a file unless I close all excel instances or it's th. BVBOWES Excel Discussion (Misc queries) 0 April 26th 05 09:20 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM


All times are GMT +1. The time now is 02:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"