Prev: Unable to add table
Next: CustomUI
From: Graham Mayor on 12 Mar 2010 02:18 You are welcome :) -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> 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:63a61300-c0bc-4d20-a80a-37ff0fa2d19e(a)g28g2000yqh.googlegroups.com... 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 |