20190318wdVBA_替换下划线

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

  

原文地址:https://www.cnblogs.com/nextseven/p/10552099.html