My document has a paragraph style named "myData." When I select one
paragraph and run this subroutine:
For Each para In Selection.Paragraphs
para.Style = myData
Next para
I get the following error message:
"One of the values passed to this method or property is out of range,"
and the line:
para.Style = myData
is highlighted.
What am I doing wrong?
Stefan Blom - 11 Nov 2004 11:51 GMT
Put myData within double quotation marks, and it should work fine:
For Each para In Selection.Paragraphs
para.Style = "myData"
Next para
Without the quotes, Visual Basic for Applications thinks that myData
is a variable rather than a string value.

Signature
Stefan Blom
> My document has a paragraph style named "myData." When I select one
> paragraph and run this subroutine:
[quoted text clipped - 16 lines]
>
> What am I doing wrong?
Helmut Weber - 11 Nov 2004 11:59 GMT
Hi Keith,
try
para.Style = "myData"
And besides that, if you select one (1) paragraph,
"for each" is useless. You don't even have to select
the paragraph at all, it is sufficient, if the insertion
point is in that paragraph.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/