Expanding a Selection

T

Thomas M

Word 2000

I have a document were sections of text are separated by message markers.
The markers are "---------------".

I'm writing a macro that positions the cursor at the top of a message,
and then expands the selection from that point to the next message
marker. The number of lines and paragraphs between message markers
varies, so I can't just expand the selection a set number of lines or
paragraphs.

Currently, my macro is capable of positioning the cursor correctly, and
finding the next message marker. But I haven't figured out how to make
it select all the text between those two locations.

How can I do that?

--Tom
 
L

Larry

You need to turn on Selection.Extend before you run the Find. This code
assumes that you've already placed the macro at the beginning of the
text following the preceding marker.


Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "------"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
End With
Selection.Find.Execute
Selection.MoveUp Unit:=wdParagraph, Count:=1, Extend:=wdExtend

Larry
 

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