20190318wdVBA_替换下划线

时间:2021-09-06 17:00:02
Sub 替换下划线()
    Selection.HomeKey wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Font.Underline = wdUnderlineThick
    Selection.Find.Replacement.ClearFormatting
    'Selection.Find.Replacement.Font.Underline = wdUnderlineThick
    With Selection.Find
        .Text = "[!^13^l]"
        .Replacement.Text = "__"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    

    
    Selection.HomeKey wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Font.Underline = wdUnderlineSingle
    Selection.Find.Replacement.ClearFormatting
    'Selection.Find.Replacement.Font.Underline = wdUnderlineThick
    With Selection.Find
        .Text = "[!^13^l]"
        .Replacement.Text = "__"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub