Group: microsoft.public.word.vba.general
From: "Graham Mayor"
Date: Saturday, March 08, 2008 4:35 AM
Subject: Re: Exiting a Sub in Word 2003

Wouldn't it make more sense to have

Sub MyWondrousInvention()
Userform_1_FRM.Show
End Sub

and

Private Sub ExitCMD_Click()
Unload Me
Userform_2_FRM.Show
End Sub

with additional sub routines called as required from each of the two user
forms?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Alan Stancliff wrote:
> Here's another VBA question for the Word 2003 macro experts.
>
> Suppose I have a macro like this:
>
> Sub MyWondrousInvention()
> Userform_1_FRM.Show
> Userform_2_FRM.Show
> End Sub
>
> As you can guess, the two items that "Show" are two user forms. The
> first user form has a CANCEL button on it, and the code looks like
> this:
> Private Sub ExitCMD_Click()
> Userform_1_FRM.Hide
> Unload Userform_1_FRM
> End Sub
>
> What I would like is that if the first user form exits because the
> CANCEL button is pressed, the second user form does not and the
> MyWondrousInvention sub is exited without the second step being
> activated. But because the click routine is private, I can't figure
> out how to make it abort the rest of the sub. I suppose some
> if-else-then routine, but how does one do it in this case?
>
> Regards,
>
> Alan Stancliff