Group: microsoft.public.word.vba.general
From: Tony Strazzeri
Date: Wednesday, March 26, 2008 8:48 PM
Subject: Re: VBA question

On Mar 27, 5:01=A0am, Edward wrote:
> Hi everybody,
> What is the difference between these two codes
> dim sec as section
> if sec.Range.Paragraphs(1).Range.Style=3D"..." then
>
> and
> dim sec as section
> if sec.Range.Paragraphs(1).Style=3D"..." then
>
> the first version which is a amll pert of my code sometimes generates erro=
r
> when paragraph marker if off but when I turn on the paragraph marker it wo=
rks!
>
> so I wonder what does that addition .Range do in the code.
> --
> Best regards,
> Edward

Hi Edward,

I'm Using Word 2002 SP3.

Dim sec As Section
Set sec =3D ActiveDocument.Sections(1)
If sec.Range.Paragraphs(1).Range.Style =3D "Heading 1" Then MsgBox
"1).Range.Style =3D"

If sec.Range.Paragraphs(1).Style =3D "Heading 1" Then MsgBox "1).Style =3D
"


Both work OK for me under both circumstances.

Hope this helps.

Cheers!
TonyS.