KapTheHat
asked on
VBA Word - Find / Replace
I am trying to use VBA to do Find / Replace in Word. I have used the macro recorder as a starting point but it doesn't work. I have given a section of the code below. It does n't like the find / text approach. Thanks
Kaps
Kaps
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim Doc_to_Open As string
Dim old_First_Name as String
Dim new_First_Name as String
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Doc_To_Open = Sheets("Front Sheet").ComboBox2.Value
Set wrdDoc = wrdApp.Documents.Open(Full_Doc_Name)
With wrdDoc.find
.text =Old_First_Name
.replacement.text = New_First_name
end with
Old_first_name = new_first_name
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It's the literal value to Replace All (I guessed that was what you wanted?)
ASKER
Thanks. much appreciated. will test out later today and get back to you.
ASKER
Kaps