Edward wrote:
> Hi Tony,
> There must be a difference between these two code I know it works most of
> the times but not always ! In fact sometimes there is no
> sec.Range.Paragraphs(1).Range.Style ( there is no range for paragraph(1) !)
> but for the same situation the following code sec.Range.Paragraphs(1).Style
> works another words there is no range for paragraph 1, but there is a style
> for paragraph 1. so I dont know the difference between these two codes .
>
>
sec.Range.Paragraphs(1).Range
This gets the range of the first paragraph in the document. I believe
there will always be one of these because even a blank document
contains at least one (empty) paragraph.
sec.Range.Paragraphs(1).Range.Style
will return the stylename of the style applied to the paragraph (1)'s
range.
I don't believe there is any functional diffeence betwen that and
sec.Range.Paragraphs(1).Style
Are you making sure that sec is assigned a value in both cases?
in my example I specifically used
Set sec = ActiveDocument.Sections(1)
Hope this helps.
Cheers!
TonyS.