Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    ApplicationEventHandler Unloading (Word 2002/Office XP)

    Very long piece of code moved to attachment by HansV

    Hello,

    I'm finding that in XP my application EventHandler at some point becomes unloaded or not registered. Is there something in my code below that might be causing the EventHandler to unload? Or is there a way to check to see if the EventHandler is registered when a document is open? Any help would be appreciated. Thanks.

    Kyle

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

    Re: ApplicationEventHandler Unloading (Word 2002/Office XP)

    You have error handlers in the event procedures you posted, but if you have other code without error handling, an error in that code would clear all variables, including objWord.

  3. #3
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: ApplicationEventHandler Unloading (Word 2002/Office XP)

    I have error handlers in just about all my code and I'm not getting any run-time errors on procedures that don't have an error handler.

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

    Re: ApplicationEventHandler Unloading (Word 2002/Office XP)

    In that case, I have no explanation; I hope that someone else will be able to help.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: ApplicationEventHandler Unloading (Word 2002/Office XP)

    The way that you terminate an error handler could be important for maintaining the event variable. In some cases, you are using Exit Sub, which I suspect does not have the same effect as Resume. Please see <post#=292116>post 292116</post#> for additional musings.

  6. #6
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: ApplicationEventHandler Unloading (Word 2002/Office XP)

    Thanks. I guess I don't understand. I don't think I want any Resume or Resume Next because my error trapping is catching things like protected documents or objects that have been deleted and in those cases It would not be appropriate to resume because I would continue to receive errors, right? Would err.clear in place of exit sub be better?

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: ApplicationEventHandler Unloading (Word 2002/Office XP)

    I think you could do this:

    Create a label just before End Sub:

    ByeBye:

    Then, in your error hander, instead of using Exit Sub, use:

    Resume ByeBye

    This should at least rule out the issue as a possible source of the problem.

Posting Permissions

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