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 / August 2005

Tip: Looking for answers? Try searching our database.

Determining Paragraph Style Following a Selection Object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don - 24 Aug 2005 22:06 GMT
I am looking for a way to determine the style of a paragraph following the
current selection object.  In short, if the paragraph following the
selection object is a certain style, I need to move the end of the selection
object to the end of that paragraph.  Initially my plan was to add the
paragraph and test the style (strStyle = Selection.ParagraphFormat.Style),
however, if more than one paragraph is in the selection object, strStyle is
"Nothing".  (This makes sense if there are multiple styles in the
selection.)

Is there a way to way to get the Paragraph number of the current selection
and then test Paragraph (number+1)?

Unfortunately, I am a relative newbie to Word VBA, so only really know how
to work selection objects.  But in this case I almost need two.

Any suggestions, references, links, comments, etc. will be greatly
appreciated!

Thanks!

Don
Edward Thrashcort - 24 Aug 2005 22:58 GMT
strStyle = Selection.Paragraphs.Last.Style

Eddie

> I am looking for a way to determine the style of a paragraph following the
> current selection object.  In short, if the paragraph following the
[quoted text clipped - 19 lines]
>
> Don
Jezebel - 24 Aug 2005 23:24 GMT
You need to create a range to point to the text immediately following the
selection:

If ActiveDocument.Range(Selection.Range.End + 1, Selection.Range.End +
1).Style = strStyle then
   ...

You might want to add some error handling in case the Selection includes the
end of document.

>I am looking for a way to determine the style of a paragraph following the
> current selection object.  In short, if the paragraph following the
[quoted text clipped - 19 lines]
>
> Don
Don - 25 Aug 2005 14:34 GMT
strStyle = Selection.Paragraphs.Last.Style did the trick!

Thanks!

Don

>I am looking for a way to determine the style of a paragraph following the
> current selection object.  In short, if the paragraph following the
[quoted text clipped - 19 lines]
>
> Don
 
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.