Re: All search & replace lines needed? by Jezebel
Jezebel
Fri Feb 10 21:29:09 CST 2006
I don't know what the technical limit is for choose() -- but for more than
about a dozen items (as you have), it's impractical: it's too hard to see
what's going on with your code.
In your case, it would be better to set up an array --
Dim pText(1 to n, 1 to 2) as string
pText(1,1) = "del^p" : pText(1,2) = "delivery^p"
:
With as many items as you have, you might want to set this up in a table or
a spreadsheet, where it's easier to maintain.
For i = 1 to n
.Text = pText(i,1)
.Replacement.Text = pText(i,2)
:
The i = 1 to 14 was my misreading of your question. I thought you had 14
replacements to do.
"slangist" <slangist@yahoo.com> wrote in message
news:EF138135-E859-4262-8CCF-C91FC2684E20@microsoft.com...
> Thanks! If I do it this way, how many entries can I have in
>
> Text = Choose(i, "..", "...", "..."....)
> and
> Replacement Text = Choose(i, "..", "...", "..."....)
> ?
>
> I am up to 256 terms now, with a probable upper limit of 500.
>
> And what is the function of the
>
> For i = 1 to 14
>
> statement?
>
> Appreciate all the help!
>
> "Jezebel" wrote:
>
>> Yes you can omit those. Simpler still is to use a loop, with the changing
>> values in variables --
>>
>> With Selection.Find
>> For i = 1 to 14
>> .Text = Choose(i, "del^13", "...", "..."....)
>> .Replacement.Text = Choose(i,"delivery^p", "...", "......)
>> .Forward = True
>> .Wrap = wdFindContinue
>> .Format = False
>> .MatchCase = True
>> .MatchWholeWord = False
>> .MatchWildcards = False
>> .MatchSoundsLike = False
>> .MatchAllWordForms = False
>> .Execute Replace:=wdReplaceAll
>> Next
>> End with
>>
>>
>> "slangist" <slangist@yahoo.com> wrote in message
>> news:33B89791-6E8A-4F1F-BE7D-C8082BBF5243@microsoft.com...
>> >I am doing a long Word search-and-replace macro in 14-line chunks
>> >exemplified
>> > as follows:
>> >
>> > With Selection.Find
>> > .Text = "del^13"
>> > .Replacement.Text = "delivery^p"
>> > .Forward = True
>> > .Wrap = wdFindContinue
>> > .Format = False
>> > .MatchCase = True
>> > .MatchWholeWord = False
>> > .MatchWildcards = False
>> > .MatchSoundsLike = False
>> > .MatchAllWordForms = False
>> > End With
>> > Selection.Find.Execute Replace:=wdReplaceAll
>> >
>> > Of those lines above, these never change:
>> > .Forward = True
>> > .Wrap = wdFindContinue
>> > .Format = False
>> > .MatchWholeWord = False
>> > .MatchWildcards = False
>> > .MatchSoundsLike = False
>> > .MatchAllWordForms = False
>> >
>> > Am I allowed to expunge those lines from each of the 14-line blocks
>> > since
>> > they are always the same and, presumably, are at default values? Or do
>> > I
>> > at
>> > most just have to keep the .Wrap statement?
>> >
>>
>>
>>