For some reason, if you use the macro recorder while doing the search and replace described above, the resulting macro doesn't work. Through trial and error I found that you need to insert a line of code into the macro, so that it reads:
Code:
Sub UnderscoreToItal()
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "_(*)_"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.Replacement.Font.Italic = wdToggle
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "_"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub