+ Reply to Thread
Results 1 to 10 of 10

Close all Instances of Excel

Hybrid View

Guest Close all Instances of Excel 02-18-2005, 10:06 AM
Guest RE: Close all Instances of... 02-18-2005, 12:06 PM
Guest RE: Close all Instances of... 02-18-2005, 03:00 PM
Guest RE: Close all Instances of... 02-18-2005, 03:00 PM
Guest Re: Close all Instances of... 02-22-2005, 11:06 AM
Guest Re: Close all Instances of... 02-22-2005, 12:06 PM
Guest Re: Close all Instances of... 02-22-2005, 12:06 PM
Guest Re: Close all Instances of... 02-22-2005, 12:06 PM
  1. #1
    Tod
    Guest

    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. #2
    AA2e72E
    Guest

    RE: 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. #3
    quartz
    Guest

    RE: Close all 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?
    > >


  4. #4
    quartz
    Guest

    RE: Close all 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?
    > >


  5. #5
    Tod
    Guest

    Re: 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?
    > >



  6. #6
    Tom Ogilvy
    Guest

    Re: 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" <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?
    > > >

    >




  7. #7
    Tod
    Guest

    Re: 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.


  8. #8
    Tod
    Guest

    Re: 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.



  9. #9
    Tom Ogilvy
    Guest

    Re: 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" <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.
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1