M
Matt
Hi all:
I am trying to run a macro from excel to open up a word document called
doc1.doc on C:\doc1.doc and do a find and replace in the word document.
I have the code written below and it does the search but it does not
do the replace. Please help as I have been pulling my hair out.
Thanks in advance.
Sub Find_and_Replace()
Dim appWD As Object
Set appWD = CreateObject("Word.Application")
appWD.documents.Open("C:\Doc1.doc").Application.Visible = True
With appWD.Visible = True
With appWD.Application.Selection.Find
.Text = "Date"
.Replacement.Text = "Time"
.Forward = True
.Wrap = wdFindContinue
End With
Do While appWD.Application.Selection.Find.Execute
appWD.Application.Selection.Find.Execute Replace:=wdReplaceAll
Loop
End With
End Sub
I am trying to run a macro from excel to open up a word document called
doc1.doc on C:\doc1.doc and do a find and replace in the word document.
I have the code written below and it does the search but it does not
do the replace. Please help as I have been pulling my hair out.
Thanks in advance.
Sub Find_and_Replace()
Dim appWD As Object
Set appWD = CreateObject("Word.Application")
appWD.documents.Open("C:\Doc1.doc").Application.Visible = True
With appWD.Visible = True
With appWD.Application.Selection.Find
.Text = "Date"
.Replacement.Text = "Time"
.Forward = True
.Wrap = wdFindContinue
End With
Do While appWD.Application.Selection.Find.Execute
appWD.Application.Selection.Find.Execute Replace:=wdReplaceAll
Loop
End With
End Sub