1
我已经有了使用VBA宏在Microsoft Word中进行搜索和替换的代码,但此刻,我的代码正在复制和粘贴多次相同的函数。搜索并替换多个词
我希望做的是有一个需要更换的话的词典,所以例如:
old_word:new_word
然后,我必须通过VBA脚本中循环,并进行必要的文档中的更改。
我现在的代码是,并重复每个新的单词对。
Sub change_words()
With Selection.Find
.Text = "optimize"
.Replacement.Text = "optimise"
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "utilized"
.Replacement.Text = "utilised"
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
提前感谢