+ Reply to Thread
Results 1 to 12 of 12

Close/Reopen Excel using Taskkill - possible?

  1. #1
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Close/Reopen Excel using Taskkill - possible?

    Hi there,

    I have the following code that needs to execute. Basically, every once in a while, our terminal program encounters an error that makes it so Excel and it can't talk to each other. The only way to fix this is by killing the entire process tree of both terminal and Excel, or restarting the computer. I've written this bit of code in the event it starts happening while someone is using the macro - it checks to see if the two can talk, and if they can't, it just kills both programs.

    Please Login or Register  to view this content.
    Obviously, since the last line is:
    Please Login or Register  to view this content.
    That's the last thing Excel does before it goes and commits suicide, so I can't have any line after that. Is there any way for me, before hand, to like... launch Excel with a 8 second delay, so that once the kill command executes, Excel re-opens? Or could I write a batch file with delay built in to execute prior to the kill command? I could use Shell to execute that prior to killing Excel, but I'm not sure if that's possible....

  2. #2
    Forum Contributor
    Join Date
    08-27-2009
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    217

    Re: Close/Reopen Excel using Taskkill - possible?

    How about after clicking YES you call up a .bat file that kills the excel.exe task and launch it again? I have an example for you if that is something you are looking at.

  3. #3
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Close/Reopen Excel using Taskkill - possible?

    That's exactly what went through my head after I posted this... I created a batch file that reads:

    Please Login or Register  to view this content.
    and that works perfectly - as by the time those 5 seconds are up, the macro has finished running and killing Excel.

    The issue is - I don't know how to run it... I found a few things on various forums, but none of them seem to work. Here's my code now:

    Please Login or Register  to view this content.
    But I just get a blank CMD window opening... I've messed around with a few different things and I can't get that path to go into the CMD window.

  4. #4
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270

    Re: Close/Reopen Excel using Taskkill - possible?

    Is there a reason why you have to close excel the application? Would it work if you just close the workbook its pertaining to and reopen the workbook?

  5. #5
    Forum Contributor
    Join Date
    08-27-2009
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    217

    Re: Close/Reopen Excel using Taskkill - possible?

    Quote Originally Posted by Sniper View Post
    How about after clicking YES you call up a .bat file that kills the excel.exe task and launch it again? I have an example for you if that is something you are looking at.
    This is the code that you must call in excel:
    Please Login or Register  to view this content.
    Just create the batfile then to kill: pcscm.exe, pcsws.exe, excel.exe and then restart them

  6. #6
    Forum Contributor
    Join Date
    08-27-2009
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    217

    Re: Close/Reopen Excel using Taskkill - possible?

    Here is example of bat
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Close/Reopen Excel using Taskkill - possible?

    that makes a lot more sense to do it that way actually............ Thanks man! Good idea.

  8. #8
    Forum Contributor
    Join Date
    08-27-2009
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    217

    Re: Close/Reopen Excel using Taskkill - possible?

    Quote Originally Posted by lordterrin View Post
    that makes a lot more sense to do it that way actually............ Thanks man! Good idea.
    Pleasure!!

  9. #9
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Close/Reopen Excel using Taskkill - possible?

    two questions on this though:

    1. What does the /c do?
    2. My path name has spaces in it, and I can't change that. When I execute, VBA says "file not found," but I'm sure the file path is correct. How do I work with the spaces inherent in the file path?

  10. #10
    Forum Contributor
    Join Date
    08-27-2009
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    217

    Re: Close/Reopen Excel using Taskkill - possible?

    Quote Originally Posted by lordterrin View Post
    two questions on this though:

    1. What does the /c do?
    2. My path name has spaces in it, and I can't change that. When I execute, VBA says "file not found," but I'm sure the file path is correct. How do I work with the spaces inherent in the file path?
    Put it in " " i.e "C:\My Folder\test.bat"
    If your Dreams don't scare you......They are not big enough

    If you like my answer don't forget to click on the *

  11. #11
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Close/Reopen Excel using Taskkill - possible?

    Please Login or Register  to view this content.
    File Not Found But the file's there

  12. #12
    Forum Contributor
    Join Date
    08-27-2009
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    217

    Re: Close/Reopen Excel using Taskkill - possible?

    Quote Originally Posted by lordterrin View Post
    Please Login or Register  to view this content.
    File Not Found But the file's there
    Ok this will work:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] macro close without saving reopen
    By g48dd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-09-2010, 10:27 PM
  2. save,close then reopen original
    By stevesunfold in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2008, 02:32 PM
  3. [SOLVED] How to show gridlines when I close & reopen without having to go
    By Shorty in forum Excel General
    Replies: 1
    Last Post: 07-16-2006, 05:44 PM
  4. Replies: 1
    Last Post: 07-04-2006, 04:20 PM
  5. [SOLVED] VBA Code dosent run after close & reopen
    By Jagdip Singh Ajimal in forum Excel General
    Replies: 2
    Last Post: 04-25-2005, 09:06 AM

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