Monday, April 27, 2009

How to Kill the Word Process using VBA

Developers who are working on Word VBA would have experienced the Word Crash problem more often.

Here is a crude way to kill the Word process.
Sub Kill_Word()

Dim sKillWord As String

sKillWord = "TASKKILL /F /IM Winword.exe"

Shell sKillWord, vbHide

End Sub


Process Window

Use this option if you are sure that the process is unused one

8 comments:

  1. Anonymous2:05 AM

    Thank you
    You saved the day

    ReplyDelete
  2. Thanks! This was exactly what I needed.

    ReplyDelete
  3. Anonymous11:51 AM

    Doesn't work for me in XP get a 53 error message

    ReplyDelete
    Replies
    1. Anonymous9:05 PM

      53 means file not found, so winword.exe is probably already closed.

      Delete
  4. Anonymous3:13 AM

    u saved my life, finally that works... ty :)

    ReplyDelete
  5. thankyou! thankyou! thankyou!
    however, if you are running this in excel you may wait to put a wait in after it. I make mine wait 5 secs and everything works fine afterwards

    ReplyDelete
  6. Very helpful thanks just what was needed

    ReplyDelete
  7. Very Helpful. just what was needed when word continues as background process after
    set WrdApp = Nothing

    ReplyDelete

StumbleUpon
Share on Facebook
Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.