Group: microsoft.public.word.vba.general
From: =?Utf-8?B?RWxhaW5lIEou?=
Date: Tuesday, April 08, 2008 4:56 PM
Subject: Re: ending multiple if/with statements

Jonathan, thank you so much. It sometimes goes several months between times
when I need to write some code. It seems like every time, I get this mixed
up. Thank you for a clear answer. I can keep this with my samples.

"Jonathan West" wrote:

>
> "Elaine J." wrote in message
> news:5D596AC0-0F17-4B91-89B0-4890A3DD82C6@microsoft.com...
> >I have what I know has to be a very basic programming question. But I
> >always
> > have trouble with this and have not been able to locate an answer that has
> > made it clear to me.
> >
> > When you have multiple if and with statements: what is the proper
> > sequence
> > to end them.
> >
> > for example
> >
> > if
> > with
> > with
> > if
> >
> > I need to end the two "with" statements and the last "if", but not the
> > first
> > one just yet. what is the proper sequence to end them?
> >
> > end with
> > end with
> > end if
> >
> > OR
> >
> > end if
> > end with
> > end with
> >
> > If someone could explain how to know what the sequence should be, I would
> > greatly appreaciate it. Thanks.
> >
>
> Such statement pairs should always be nested, not overlapping. It is easier
> to keep track if you indent code within these structures, as follows
>
> If A then
> With B
> With C
> If D Then
>
> End If 'from If D
> End With 'from With C
> End With 'from With B
> End If 'from If A
>
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
>
>
>

Safety Articles | Usenet Groups | Usenet News | Bluegrass