I guess this is more of a vbscript question, but what
would be the best code to close all open 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?
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?
>
That's pretty cool. I didn't know you could do something like that. Thanks.
"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?
> >
Another question: Is there a way to call that script from inside VBA?
"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?
> >
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?
> >
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" <todtown@swbell.net> wrote in message
news:1109083928.512342.311570@c13g2000cwb.googlegroups.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?
> > >
>
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.
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.
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" <todtown@swbell.net> wrote in message
news:1109086272.328778.189760@g14g2000cwa.googlegroups.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.
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks