Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

error when changing a paragraph style

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
keith brickey - 11 Nov 2004 03:40 GMT
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/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.