From: wtbx on
Control+clicking on any part of a sentence selects the whole sentence,
using a full mark as a delimiter.

Is it possible to create a macro that would use a semicolon as segment
delimiter?

Thanks for any ideas

Wtbx

From: Jonathan West on

"wtbx" <weetabx(a)hotmail.com> wrote in message
news:79795181-4923-4f92-8995-2f73dc24d64d(a)u9g2000yqb.googlegroups.com...
> Control+clicking on any part of a sentence selects the whole sentence,
> using a full mark as a delimiter.
>
> Is it possible to create a macro that would use a semicolon as segment
> delimiter?
>
> Thanks for any ideas
>
> Wtbx
>

Try this

Sub ExtendtoSemiColon
With Selection
.MoveEndUntil Cset:=";", Count:=wdForward
.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End With
End Sub

--
Regards
Jonathan West

From: Fumei2 via OfficeKB.com on
Ctrl-click moves both forward and backward. In other words, if you are three
words into a sentence, Ctrl-Click will select the previous words, AS WELL AS
the remaining words of the sentence.

Jonathan's code moves forward to the first ";"

Is this sufficient? If not, please detail exactly what you are trying for.
To get the previous words of the sentence included, try:

With Selection
.Expand Unit:=wdSentence
.Collapse 1
.MoveEndUntil Cset:=";", Count:=wdForward
.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End With

This expands to the whole sentence, collapses to the Start, then moves the
End to the first ";" (and then moves again to include the ";").

Jonathan West wrote:
>> Control+clicking on any part of a sentence selects the whole sentence,
>> using a full mark as a delimiter.
>[quoted text clipped - 5 lines]
>>
>> Wtbx
>
>Try this
>
>Sub ExtendtoSemiColon
> With Selection
> .MoveEndUntil Cset:=";", Count:=wdForward
> .MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
> End With
>End Sub
>

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/201003/1

From: Doug Robbins - Word MVP on
The following code will select the text from the present location of the
insertion point (selection) to and including the next semicolon (if there is
one)

Dim myrange As Range
Set myrange = Selection.Range
myrange.End = ActiveDocument.Range.End
If InStr(myrange, ":") > 0 Then
myrange.End = myrange.Start + InStr(myrange, ";")
myrange.Select
Else
MsgBox "There is no semicolon between the location of the insertion
point and the end of the document."
End If


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"wtbx" <weetabx(a)hotmail.com> wrote in message
news:79795181-4923-4f92-8995-2f73dc24d64d(a)u9g2000yqb.googlegroups.com...
> Control+clicking on any part of a sentence selects the whole sentence,
> using a full mark as a delimiter.
>
> Is it possible to create a macro that would use a semicolon as segment
> delimiter?
>
> Thanks for any ideas
>
> Wtbx
>
From: wtbx on
Thank you both very much for you prompt replies and your help.

Fumei, your macro does almost what I'm looking for. Here is a better
explanation of what I'd like the macro to do:

Let's say we have the followingsentence, which includes 3 segments.

--- sentence starts here
This is the first segment; this is the second segment; this is the
third segment.
--- sentence stops here

I would like a macro that, when I click on any part of a particular
segment, would choose the whole of that segment.

So, if i clicked on the word "first", the macro would select: "This is
the first segment;"
If I clicked on the word "second", the macro would select: "this is
the second segment;"
If I clicked on the word "third", the macro would select: "this is the
third segment."

Do you think this could be done?

I appreciate any help, because I am totally VBA-illiterate but such a
macro would help me immensely in my work!

Thanks again for your time

Wtbx

On 10 Μαρ, 20:53, "Fumei2 via OfficeKB.com" <u53619(a)uwe> wrote:
> Ctrl-click moves both forward and backward.  In other words, if you are three
> words into a sentence, Ctrl-Click will select the previous words, AS WELL AS
> the remaining words of the sentence.
>
> Jonathan's code moves forward to the first ";"
>
> Is this sufficient?  If not, please detail exactly what you are trying for.
> To get the previous words of the sentence included, try:
>
> With Selection
>    .Expand Unit:=wdSentence
>    .Collapse 1
>    .MoveEndUntil Cset:=";", Count:=wdForward
>    .MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
> End With
>
> This expands to the whole sentence, collapses to the Start, then moves the
> End to the first ";" (and then moves again to include the ";").
>
>
>
>
>
> Jonathan West wrote:
> >> Control+clicking on any part of a sentence selects the whole sentence,
> >> using a full mark as a delimiter.
> >[quoted text clipped - 5 lines]
>
> >> Wtbx
>
> >Try this
>
> >Sub ExtendtoSemiColon
> >  With Selection
> >    .MoveEndUntil Cset:=";", Count:=wdForward
> >    .MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
> >  End With
> >End Sub
>
> --
> Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/word-programming/201003/1

 |  Next  |  Last
Pages: 1 2 3
Prev: Unable to add table
Next: CustomUI