不打开WORD文档批量替换文档内容
Sub 批量替换WORD内容()
Dim wd As New Word.Application
pa = ThisWorkbook.Path & "\111.docx"
With wd
.Documents.Open pa
.Visible = False
For i = 2 To Cells(65535, 1).End(xlUp).Row
.ActiveDocument.Content.Find.Execute findtext:=Cells(i, 1), replacewith:=Cells(i, 2), Replace:=wdReplaceAll, Forward:=True
Next
.Documents.Save
.Quit
End With
Set wd = Nothing
End Sub
posted on 2018-05-27 11:31 lizicheng 阅读(1509) 评论(0) 编辑 收藏 举报