View Single Post
Old 11-16-2007, 08:47 PM   #15
Stephanos
Connoisseur
Stephanos doesn't litterStephanos doesn't litter
 
Posts: 58
Karma: 133
Join Date: Oct 2007
Location: Minnesota, USA
Device: EB-1150, PRS-505, NST
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
Stephanos is offline   Reply With Quote