I want to search (through VBA) a string "ABC N.N", where n may be any
number, one by one till end of Document & simoultaneously add a unique value
to it, can this be possible?


Regards,

G Bahri

Re: Searching a string till eof by Doug

Doug
Tue Nov 04 02:22:23 CST 2003

Hi Girish,

The following will add 1 to each instance of ABC N.N in the document:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="ABC [0-9]{1}.[0-9]{1}",
MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
Selection.Range.Text = "ABC " & Val(Mid(Selection.Range.Text,
5)) + 1
Selection.Collapse wdCollapseEnd
Selection.MoveRight wdCharacter, 1
Loop
End With

For an explanation of the FindText string, see the article ?Finding and
replacing characters using wildcards? at:

http://www.mvps.org/word/FAQs/General/UsingWildcards.htm

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
"Girish Bahri" <gbahri@techbooks.com> wrote in message
news:uznLBuooDHA.3256@tk2msftngp13.phx.gbl...
>
> I want to search (through VBA) a string "ABC N.N", where n may be any
> number, one by one till end of Document & simoultaneously add a unique
value
> to it, can this be possible?
>
>
> Regards,
>
> G Bahri
>
>
>



Re: Searching a string till eof by Girish

Girish
Tue Nov 04 02:49:14 CST 2003

Thanks Doug,

Its working perfectly

Girish Bahri



"Doug Robbins - Word MVP" <dkr@mvps.org> wrote in message
news:en#0GzqoDHA.2456@TK2MSFTNGP09.phx.gbl...
> Hi Girish,
>
> The following will add 1 to each instance of ABC N.N in the document:
>
> Selection.HomeKey wdStory
> Selection.Find.ClearFormatting
> With Selection.Find
> Do While .Execute(FindText:="ABC [0-9]{1}.[0-9]{1}",
> MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
> Selection.Range.Text = "ABC " & Val(Mid(Selection.Range.Text,
> 5)) + 1
> Selection.Collapse wdCollapseEnd
> Selection.MoveRight wdCharacter, 1
> Loop
> End With
>
> For an explanation of the FindText string, see the article "Finding and
> replacing characters using wildcards" at:
>
> http://www.mvps.org/word/FAQs/General/UsingWildcards.htm
>
> Please post any further questions or followup to the newsgroups for the
> benefit of others who may be interested. Unsolicited questions forwarded
> directly to me will only be answered on a paid consulting basis.
>
> Hope this helps
> Doug Robbins - Word MVP
> "Girish Bahri" <gbahri@techbooks.com> wrote in message
> news:uznLBuooDHA.3256@tk2msftngp13.phx.gbl...
> >
> > I want to search (through VBA) a string "ABC N.N", where n may be any
> > number, one by one till end of Document & simoultaneously add a unique
> value
> > to it, can this be possible?
> >
> >
> > Regards,
> >
> > G Bahri
> >
> >
> >
>
>