Results 1 to 2 of 2
  1. #1
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    UserForm and WithEvents (Word 2002 SP-2)

    I'm trying to tie into a modeless UserForm's events in a class module. If I declare the relevant WithEvents object variable As MSForms.UserForm, the module compiles OK, but the available events are incomplete. (They don't include Initialize or Terminate, for example.) On the other hand, if I declare the WithEvents object variable As WForms.frmMyForm, I get the compile error "Object does not source automation events."

    WForms.frmMyForm is creatable and exposed (and in any case, in the same template as the class module). Is there something else I can tweak to make it "source automation events"?

    Alternatively, is there some other way I can declare the WithEvents variable As MSForms.UserForm but get access to the Terminate event?

    I should add that I've declared a 2nd WithEvents object variable As MSForms.CommandButton and set it to a button on the same UserForm and the _Click event procedure in the class module for that button runs fine when the button is clicked.

  2. #2
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: UserForm and WithEvents (Word 2002 SP-2)

    Well, it looks like I solved my problem. I added Event Terminate() to the declarations section of the UserForm's code module and then put RaiseEvent Terminate in the Terminate event procedure in the same code module.

    I don't really understand why this was necessary, however, so if anyone can explain ...

Posting Permissions

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