Hi Alan,
Assuming your cursor is in the right paragraph to begin with (which you'll
have to do separately) then
Selection.Paragraphs(1).Range.Select
Selection.Collapse wdCollapseStart
Selection.MoveUntil ":"
Selection.MoveRight , 3
Selection.MoveEndUntil Chr(13)
will select the paragraph, fall back to the beginning, roll forward to the
colon, then a couple spaces then stretch out to the end.
Of course you would be better not using the selection but that's for another
day :)
Does that help?
--
Enjoy,
Tony
"Alan Stancliff"
news:OfHjZNaeIHA.1208@TK2MSFTNGP05.phx.gbl...
> Thanks Tony,
>
> I looked at the help file for Selection.MoveUntil and
> Selection.MoveEndUntil.
>
> Unfortunately, I'm pretty much of a beginner at VBA, and I'm not sure what
> algorithm to use or how to use it. As you might guess, my question was a
> generalization that I devised to help me learn something to help write a
> macro. Mostly, what I have been doing is recording and editing the
> recorded stuff, while trying to read up on how VBA works.
>
> Do you think it might be possible to give me a few snippits of code that
> would do the three tasks I asked about. I would be most grateful.
>
> For anyone looking at this, below my signature line, I am restating the
> question in my original post in case you can't see it
>
> Regards,
>
> Alan Stancliff
>
> ++++++QUESTION++POSED++++++++++
>
> Supposing I have a document that somewhere has the following on a line by
> itself, effectively being a paragraph:
>
> **********
> (A) MY SAMPLE WORDS TO SELECT: Hello World
>
> and later on it has a line that has
>
> (B) MY OTHER SAMPLE WORDS TO SELECT: Hello Universe, So Vast Thou Art.
> *********
>
> Without using the search functionality, how would one code to do the
> following three tasks:
> 1. Select the the stuff following the colon and two spaces in sample (A),
> whatever it may be (in this case, "Hello World")
>
> 2. Select the stuff before the comma in my example (B), whatever it may be
> (in this case it is Hello Universe)
>
> 3 Select the stuff between the comma and end of the line (in this case, it
> is "So Vast Thou Art").
>
>
> Tony Jollans wrote:
>> Without using (built-in) search functionality you will have to write your
>> own - checking each paragraph (using any algorithm you like) until you
>> identify the one you want.
>>
>> Having identified the paragraph you can scan it and move the selection
>> within it using Selection.MoveUntil and Selection.MoveEndUntil and other
>> similar methods.
>>