Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Prevent Word shutdown via task manager (2000/2002/2003)

    Does anybody know how to use VBA to prevent an instance of Word from being shutdown in the task manager (similar to the way you can catch Query_Unload events in VB forms and cancel a task manager shutdown)?

    Thanks...
    Dan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Prevent Word shutdown via task manager (2000/2002/2003)

    That seems dangerous to me: if Word crashes (as it does sometimes), the user won't be able to kill it. Not a pleasant situation.

  3. #3
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent Word shutdown via task manager (2000/2002/2003)

    Hans--

    I'm trapping all Word crashes and handling them. So--is there a way to do what I want?

    Dan

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Prevent Word shutdown via task manager (2000/2002/2003)

    Not that I am aware of.

    (Apparently you are also able to trap Word errors not caused by your code. Can you share the secret?)

  5. #5
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent Word shutdown via task manager (2000/2002/2003)

    (Edited by HansV to make URL clickable - see <!help=19>Help 19<!/help>)

    You can do this with the SetUnhandledExceptionFilter API call:

    errHandler = SetUnhandledExceptionFilter(AddressOf ExceptionFilter)

    Then declare a crash handler like the one below in either a VBA module or a module in a dll loaded into the word process, and do your handling in there:

    Public Function ExceptionFilter(ByRef ExceptionPtrs As EXCEPTION_POINTERS) As Long

    There's a good article on this at:

    http://www.ftponline.com/Archives/premier/...ay99/bb0599.pdf

    Note: The article talks about re-raising an error to the sub which originally caused the crash. This works, and is very cool. But--if your crash occurs in a VBA module but the crashhandler is declared in the activeX dll (or vice-versa), re-raising the error never gets back to the faulting code. Apparently, the activeX dll and the vba code handle such re-raising of errors differently.

    Dan

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Prevent Word shutdown via task manager (2000/2002/2003)

    Thanks, I didn't know about that. Learned something new.

  7. #7
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Tallahassee, Florida, USA
    Posts
    901
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent Word shutdown via task manager (2000/2002/2003)

    Very cool! Thanks for sharing.
    Karen

Posting Permissions

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