Re: UserForm Is A Class






"Greg Maxey" <gmaxey@xxxxxxxxxxxxxxxxxxx> wrote in message news:eSXLlQd$FHA.3568@xxxxxxxxxxxxxxxxxxxxxxx
Jonathan,

You said:
No. This syntax will also cause the QueryClose and Terminate events
to fire
Sub FunWithForms()
Dim oForm as myForm
Set oForm = New myForm
oForm.Show
End Sub

In this case, the Unload is done implictly when then routine ends and
the oForm variable goes out of scope. This triggers the QueryClose
and Terminate events.

I see the Terminate event, but not the QueryClose event.


If I call with: Sub CM6() Dim oForm As myForm Set oForm = New myForm oForm.Show Set oForm = Nothing End Sub

Debug.Print shows:
myForm initialized.
myForm activated
myForm terminated.

Ah, correct. I had forgotten that QueryClose is not triggered when the form simply drops out of scope having been hidden. That's not a case I use often.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org


.



Relevant Pages

  • Re: Declaring a UserForm name
    ... Dim oForm As New myForm ... I had to add Set oForm = Nothing ...
    (microsoft.public.word.vba.userforms)
  • Re: UserForm Is A Class
    ... This syntax will also cause the QueryClose and Terminate events ... > Sub FunWithForms() ... > Dim oForm as myForm ...
    (microsoft.public.word.vba.general)
  • Re: UserForm Is A Class
    ... This syntax will also cause the QueryClose and Terminate events ... >>> Sub FunWithForms() ... >>> Dim oForm as myForm ... >>> and the oForm variable goes out of scope. ...
    (microsoft.public.word.vba.general)
  • Re: VBA and opening an Userform
    ... Dim oForm as myform 'myform is the name that you have assigned to the ... But in Excel, I believe that the name of the macro needs to be Auto-Open ... Please respond to the Newsgroup for the benefit of others who may be interested. ...
    (microsoft.public.word.vba.userforms)

Loading