Determining Paragraph Style Following a Selection Object

D

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
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
 
J

Jezebel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top