Re: MSWord...styles. by Thomas
Thomas
Wed Jan 07 12:44:37 CST 2004
"Luke" <lcaballero@powereng.com> wrote in message
news:001f01c3d470$cd192a30$a301280a@phx.gbl...
> Hey thanks, I figured out the problem, I miss read the
> documentation. I thought the range property: style
> returned a style object, but it returns a variant. Which,
> is a string in the case, and is also what I was looking
> for.
>
> so eh... my mistake.
>
> Thanks anyway.
> L-
> >-----Original Message-----
> >Hi Luke,
> >there must something else be wrong:
> >Dim S As String
> >Dim R As Range
> >Set R = ActiveDocument.Paragraphs(4).Range
> >S = R.Style
> >MsgBox S
> >You get error 91, if the range includes more than one
> >style. Which is inconsistent compared to returning
> >other format-properties like format.character, where you
> >don't get an error, but a constant representing
> >"various" or "undefined", it is -1 I think, AFAIK.
> >Greetings from Bavaria, Germany
> >Helmut Weber
> >"red.sys" & chr$(64) & "t-online.de"
> >Word 97, W98
Luke, that's not quite correct. The Range object's Style property is a
Variant so that you can SET it with either a Style object or a string that's
the name of the style or one of the builtin style constants. When you GET
the Style property, you always get a Style object. The reason you can do S =
R.Style when S is a string is because the default property of the Style
object is NameLocal, which is a string.
-Tom