+ Reply to Thread
Results 1 to 4 of 4

Kill a second Excel process from the first excel process

  1. #1
    Registered User
    Join Date
    01-16-2012
    Location
    Philadelphia, PA, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Kill a second Excel process from the first excel process

    In Excel 2007 VBA, I open two additional workbooks. Their visible property is set to false. There are now three instances of Excel showing in Task Manager even though only one shows in the taskbar. If (or more precisely, when) an error occurs, all three instances are still there. I'd like to create an error handler to kill the two I opened in my code but not the original one that contains my code.

    I have seen numerous functions with a signature like "Function KillProcess(ProcessName as string) as Boolean". Of course, all the processes are named EXCEL.EXE. So, I need to kill these processes based on some property other than name -- perhaps process id? I'm not sure how to get the id and then use it to kill the process.

    Thanks for your help.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Kill a second Excel process from the first excel process

    At the end of your code where you are done with a particular invisible WorkBook, just add code to Close the WorkBook

    Workbooks("Name.xlsm").Saved = True
    WorkBooks("Name.xlsm").Close
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    01-16-2012
    Location
    Philadelphia, PA, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Thumbs up Re: Kill a second Excel process from the first excel process

    So simple -- and it makes such perfect sense! Thanks a million.

    I plugged in a couple of lines and everything works just as I want it to.

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Kill a second Excel process from the first excel process

    You are welcome.

    Please remember to mark your thread as solved.

+ 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