美文网首页
Word VBA Tips(2):删除中括号中的内容

Word VBA Tips(2):删除中括号中的内容

作者: highsea | 来源:发表于2017-09-04 10:26 被阅读0次
    Sub del()
    ''
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = "\[*\]"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchByte = False
            .MatchAllWordForms = False
            .MatchSoundsLike = False
            .MatchWildcards = True
        End With
        Selection.Find.Execute
        With Selection
            If .Find.Forward = True Then
                .Collapse Direction:=wdCollapseStart
            Else
                .Collapse Direction:=wdCollapseEnd
            End If
            .Find.Execute replace:=wdReplaceOne
            If .Find.Forward = True Then
                .Collapse Direction:=wdCollapseEnd
            Else
                .Collapse Direction:=wdCollapseStart
            End If
            .Find.Execute
        End With
    End Sub
    

    改良版

    
    

    相关文章

      网友评论

          本文标题:Word VBA Tips(2):删除中括号中的内容

          本文链接:https://www.haomeiwen.com/subject/ldzfjxtx.html