1. 程式人生 > >不打開WORD文檔批量替換文檔內容

不打開WORD文檔批量替換文檔內容

ace con sub active lac for work doc als


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

不打開WORD文檔批量替換文檔內容