How to select next sentence?

A

aswflyer

I am stuck on one element of a broader macro. I would like to highlight the
next sentence in preparation for executing the copy function. Here is what I
would like to happen. The macro would move the cursor to the next character
(I will have already placed the cursor before a sentence). It will then go on
to highlight the first character and subsequent characters and spaces until
it reaches either a period, question mark or exclamation mark (which it will
highlight also). The period must have a space after it to avoid the macro
stopping on a decimal point or series of dots etc. (the space after the
period should not be highlighted).

I would be very appreciative if someone could help me with the code.
 
G

Graham Mayor

You want to select the sentence the cursor is in?

Selection.Sentences(1).Select


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

aswflyer

Thank you kindly. So simple really!

Graham Mayor said:
You want to select the sentence the cursor is in?

Selection.Sentences(1).Select


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

Amigo

Hi

I found that you macro is very useful to me, but I wonder if you have an
idea how to make it keep selecting one sentence after another just buy
clicking on the icon of the macro or pressing its chortcut without having to
click inside the sentence to be selected.

Thanks a lot.
 
H

Helmut Weber

Hi Amigo,

maybe something along these lines, as
selection.Sentences(1).Next.Select
selects only the first letter in the next sentence.

Sub Macro3()
selection.Sentences(1).Next.Select
selection.Sentences(1).Select
End Sub

But note that "sentence" is a fuzzy concept of natural language
and as such not computable, at least not with todays computers.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
A

Amigo

Thanks a lot Helmut

The macro worked just like I wanted. Like a charm !

All the best.
 

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