word vba 批量多关键词替换

180it 2019-09-25 PM 4124℃ 0条
Sub aaa()
Ori = Array("a", "b", "c")  '被替换文本
Rep = Array("aa", "bb", "cc")  '替换后的文本

For i = 0 To UBound(Ori)
'MsgBox Ori(i)
      With Selection.Find
         .Text = Ori(i)
         
         .Forward = True
         .Wrap = wdFindContinue
         .Format = False             '不查找格式
         .MatchCase = False          '不区分大小写
        ' .MatchWholeWord = False     '不采用全字匹配
       '  .MatchByte = False          '不区分全半角
        ' .MatchWildcards = False     '不使用通配符
         '.MatchSoundsLike = False    '不查找同音
        ' .MatchAllWordForms = False  '不查找单词的所有形式
        .Replacement.Text = Rep(i)
     End With
     Selection.Find.Execute
     Selection.Find.Execute Replace:=wdReplaceAll
     Next

End Sub
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

word vba 批量多关键词替换