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

"Jonathan West" wrote:

>
> 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
>
>

I have never done Imbeded WITH statements before with Word. Is it possible
to do so ??

For example you have

With Selection.Range
...
With Selection.Tables(1)
...
.Font.Color = wdDarkBlue
...
End With
End With

Whick of the two will have the .FONT.COLOR changed ???

In my experience, it would be something like this

With Selection.Range
...
End With

With Selection.Tables(1)
....
End With

You could put it in a IF statement

If condition = True then
With Selection
...
end with
else
with Selection
....
end with
endif

But never

If condition = True then
With Selection
...
else
....
end with
endif

The true fork will not find an END WITH statement and the false fork will
not find the WITH statement.


--------------------------
S. Hewes