Hi Doug (or anybody else willing to help)
You gave me this bit of code:
********
Sub Testme()
Dim myrange As Range
Set myrange = ActiveDocument.Sections(1).Range
myrange.start = myrange.start + InStr(myrange, "MY OTHER SAMPLE
WORDS TO SELECT") + 32
myrange.End = myrange.start + InStr(myrange, ",") - 1
MsgBox myrange.Text
End Sub
**********
which selects the stuff between the end of the string "MY OTHER SAMPLE
WORDS TO SELECT" and a comma in a sentence that might look like this:
(B) MY OTHER SAMPLE WORDS TO SELECT: Hello Universe, So Vast Thou Art.
It works great!
But suppose that I wanted to select the stuff between the comma
following the string "MY OTHER SAMPLE WORDS TO SELECT" and the end of
the line (paragraph), and I don't know what's between the end of the
string and the paragraph mark?
Regards,
Alan Stancliff
Doug Robbins - Word MVP wrote:
> For the first one use:
>
> Dim myrange As Range
> Set myrange = ActiveDocument.Range
> myrange.start = myrange.start + InStr(myrange, "MY SAMPLE WORDS TO
> SELECT:") + 26
> myrange.End = myrange.Paragraphs(1).Range.End
> MsgBox myrange.Text
>
> and for the second
>
> Dim myrange As Range
> Set myrange = ActiveDocument.Range
> myrange.start = myrange.start + InStr(myrange, "MY OTHER SAMPLE WORDS
> TO SELECT") + 32
> myrange.End = myrange.start + InStr(myrange, ",") - 1
> MsgBox myrange.Text
>
>