From: wtbx on
Thanks Doug!

I read your message after posting the above message.

Your macro does what I want except for selecting the whole of the
segment.

Could this be included in the macro, as I explained above?

Cheers

Wtbx

On 10 Ìáñ, 22:29, "Doug Robbins - Word MVP" <d...(a)REMOVECAPSmvps.org>
wrote:
> 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" <weet...(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: Doug Robbins - Word MVP on
Creating a macro to select the whole of the second segment is quite straight
forward - the text between two semi-colons.

How though are you going to define with certainty what constitutes the start
of the first segment or the end of the last segment.

What would happen if your document contained multiple

This is the first segment; this is the second segment; this is the
third segment.
This is the first segment; this is the second segment; this is the
third segment.

and you try and select the whole of the third segment, you could end up
selecting:

this is the
third segment.
This is the first segment;

so you start having to introduce what may become quite complicated
conditions

--
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:b47132df-f99d-441f-b403-b1376754222c(a)i25g2000yqm.googlegroups.com...
> Thanks Doug!
>
> I read your message after posting the above message.
>
> Your macro does what I want except for selecting the whole of the
> segment.
>
> Could this be included in the macro, as I explained above?
>
> Cheers
>
> Wtbx
>
> On 10 ���, 22:29, "Doug Robbins - Word MVP" <d...(a)REMOVECAPSmvps.org>
> wrote:
>> 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" <weet...(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
I see, Doug. Thanks for enlightening me. So the problem would be the
third segment, not the first or the second one.

If I am not asking too much, could you possibly write a macro for
selecting just the second segment, between two semi colons, given that
my texts have that kind of segments most of the time? (OK, a macro
able to select the first one or the second one would be great, but
that *would* definetely be asking too much, I guess)

Thank you for your time and effort!

Wtbx

On 11 Ìáñ, 02:07, "Doug Robbins - Word MVP" <d...(a)REMOVECAPSmvps.org>
wrote:
> Creating a macro to select the whole of the second segment is quite straight
> forward - the text between two semi-colons.

>
> so you start having to introduce what may become quite complicated
> conditions

From: Graham Mayor on
How about a different approach?
In a given sentence containing at least one semi colon, the following should
select the segment the cursor is in (including the start and end of the
sentence).

Dim vSegment As Variant
Dim oRng As Range
Dim i As Long
vSegment = Split(Selection.Sentences(1), ";")
For i = 0 To UBound(vSegment)
Set oRng = Selection.Paragraphs(1).Range
With oRng.Find
.Text = vSegment(i)
Do While .Execute(Forward:=True) = True
If Selection.InRange(oRng) = True Then
oRng.Select
End If
Loop
End With
Next i

http://www.gmayor.com/installing_macro.htm

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



"wtbx" <weetabx(a)hotmail.com> wrote in message
news:c47b4b66-7fe8-4ca3-8371-de6045cc9db1(a)15g2000yqi.googlegroups.com...
I see, Doug. Thanks for enlightening me. So the problem would be the
third segment, not the first or the second one.

If I am not asking too much, could you possibly write a macro for
selecting just the second segment, between two semi colons, given that
my texts have that kind of segments most of the time? (OK, a macro
able to select the first one or the second one would be great, but
that *would* definetely be asking too much, I guess)

Thank you for your time and effort!

Wtbx

On 11 ���, 02:07, "Doug Robbins - Word MVP" <d...(a)REMOVECAPSmvps.org>
wrote:
> Creating a macro to select the whole of the second segment is quite
> straight
> forward - the text between two semi-colons.

>
> so you start having to introduce what may become quite complicated
> conditions


From: wtbx on
Thank you so much! It works like a charm! You have no idea how much
easier you've made my life :)

Wtbx


On Mar 11, 10:04 am, "Graham Mayor" <gma...(a)REMOVETHISmvps.org> wrote:
> How about a different approach?
> In a given sentence containing at least one semi colon, the following should
> select the segment the cursor is in (including the start and end of the
> sentence).
>
> Dim vSegment As Variant
> Dim oRng As Range
> Dim i As Long
> vSegment = Split(Selection.Sentences(1), ";")
> For i = 0 To UBound(vSegment)
>     Set oRng = Selection.Paragraphs(1).Range
>     With oRng.Find
>         .Text = vSegment(i)
>         Do While .Execute(Forward:=True) = True
>             If Selection.InRange(oRng) = True Then
>                 oRng.Select
>             End If
>         Loop
>     End With
> Next i
>
> http://www.gmayor.com/installing_macro.htm
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor -  Word MVP
>
> My web sitewww.gmayor.com
> Word MVP web sitehttp://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
> "wtbx" <weet...(a)hotmail.com> wrote in message
>
> news:c47b4b66-7fe8-4ca3-8371-de6045cc9db1(a)15g2000yqi.googlegroups.com...
> I see, Doug. Thanks for enlightening me. So the problem would be the
> third segment, not the first or the second one.
>
> If I am not asking too much, could you possibly write a macro for
> selecting just the second segment, between two semi colons, given that
> my texts have that kind of segments most of the time? (OK, a macro
> able to select the first one or the second one would be great, but
> that *would* definetely be asking too much, I guess)
>
> Thank you for your time and effort!
>
> Wtbx
>
> On 11 Ìáñ, 02:07, "Doug Robbins - Word MVP" <d...(a)REMOVECAPSmvps.org>
> wrote:
>
>
>
> > Creating a macro to select the whole of the second segment is quite
> > straight
> > forward - the text between two semi-colons.
>
> > so you start having to introduce what may become quite complicated
> > conditions

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