Group: microsoft.public.word.vba.general
From: "Jonathan West"
Date: Tuesday, April 08, 2008 12:27 PM
Subject: Re: ending multiple if/with statements


"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