MS Access VBA code to substitute values in a Word document


Sub doit()
Dim filepath As String
filepath = CurrentProject.Path & "\findme.docx"
Dim wd As Word.Application
Set wd = CreateObject("Word.Application")
With wd
.Visible = True
.Documents.Open (filepath)
.Windows(1).Visible = True
.ActiveDocument.Content.Find.Execute "findme", , , , , , , , , "foundww", wdReplaceAll
.ActiveDocument.SaveAs "found.docx"
.Quit
End With
End Sub