Find/Replace formatting

M

Mark

In Word 2003, is there a way to reformat all occurrences of *part* of
recurring text? Specifically, I want all occurrences of [sic] to be replaced
with *only* sic in italics (not the brackets). I do not want to replace
every occurrence of 'sic' since it is part of such words as basic.

I've tried using Edit>Replace>Format>Font, but I can't find a way to replace
*only* 'sic' and not the brackets, without replacing the occurrences of this
sequence of letters in other words.

Any help is much appreciated.
 
J

Jay Freedman

You need to use wildcards.

After checking the 'Use wildcards' box, enter in the Find What box

(\[)(sic)(\])

Enter in the Replace With box

\2

and press Ctrl+I to turn on italic formatting for the replacement.
Then click the Replace All button.

The article http://www.gmayor.com/replace_using_wildcards.htm will
explain what the various parts of these expressions do.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
G

Graham Mayor

If you want to retain the upright square brackets, (Jay's method will remove
the brackets) then you will need to do this in at least two stages. The
following macro will retain the upright brackets and italicise 'sic' between
them.

It works here by replacing the square brackets with unique strings and
italicising the lot, then replacing the unique strings with the left and
right upright brackets. This allows for the fact that you may have used
square brackets elsewhere. http://www.gmayor.com/installing_macro.htm

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\[(sic)\]"
.Replacement.Text = "#&#&#\1#@#@#"
.Replacement.Font.Italic = True
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "#&#&#"
.Replacement.Text = "["
.Replacement.Font.Italic = False
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "#@#@#"
.Replacement.Text = "]"
.Replacement.Font.Italic = False
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top