Sub 替换()
On Error GoTo xxx:
Dim Rng As Range, n&, arr, a$
a = ActiveDocument.Content.Text
Set Rng = ActiveDocument.Content
With Rng.Find
.ClearFormatting
.Replacement.ClearFormatting
arr = Array("白日依山尽", "黄河入海流", "欲穷千里目", "更上一层楼")
Do While .Execute(findtext:="白日依山尽")
Rng = arr(n)
Rng.SetRange Rng.End, ActiveDocument.Content.End
n = n + 1
Loop
End With
GoTo yyy:
xxx:
MsgBox "文档中词条“白日依山尽”数目超出4个!"
yyy:
MsgBox "转换完成!"
End Sub
温馨提示:答案为网友推荐,仅供参考