ML
Fri Jan 20 10:00:25 CST 2006
Is there a way to suppress the message displayed that the replace has
reached the end of the document and a way to ensure it does the replace from
top to bottom regardless of start position?
"Jean-Guy Marcil" <NoSpam@LeaveMeAlone> wrote in message
news:Orvmi0UHGHA.1288@TK2MSFTNGP09.phx.gbl...
> ML was telling us:
> ML nous racontait que :
>
>> Great thanks! The tags with wildcard search and replace should do
>> the trick for my needs.
>>
>> For the replacement, how do you specify it to remove the tags but
>> leave the wildcard portion text?
>> i.e. find <i>my text</i> and replace it with just "my text" in
>> italics where in "my text" could be any text value.
>
> The code works as is.
>
> In the first part:
>
> With Selection.Find
> .ClearFormatting
> .Text = "(\<b\>)(*)(\<\\b\>)"
>
> 'means find a <b> tag followed by any text (*)
> 'and followed by a <\b> tag.
> 'The() create groups and the \ character tells the
> 'Find engine to find the character following
> 'the "\" as is, not as a special character.
>
> .MatchWildcards = True
>
> 'use wild cards so that we can create groups and
> 'use * for any characters
>
> With .Replacement
> .ClearFormatting
> .Text = "\2"
>
> 'replace the found text by whatever the second group is
> '(i.e, delete groups 1 and 3, or the tags)
>
> .Font.Bold = True
>
> 'and set to bold
>
> End With
> .Execute Replace:=wdReplaceAll
>
> 'do it
>
> .Text = "(\<i\>)(*)(\<\\i\>)"
>
> 'change the "Find" string
>
> With .Replacement
> .ClearFormatting
>
> 'since the "Replace by" string is not mentioned,
> ' it will use the one from before ("\2")
>
> .Font.Italic = True
>
> 'but set to italic, not bold
>
> End With
> .Execute Replace:=wdReplaceAll
>
> 'do it
>
> End With
>
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site:
http://www.word.mvps.org
>