Code:
Sub Replacing()
Dim sFile As String
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
sFile = "Pack"
Set wrdApp = New Word.Application
With wrdApp
.Visible = True
Set wrdDoc = .Documents.Open("C:\Users\Admin\Desktop\" + sFile + ".doc")
With .Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "NAME1" + "NAME2"
.Replacement.Text = Range("C2") + Range("C3")
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
End With
End Sub
.Text = "NAME1"
.Replacement.Text = Range("C2")
This works for all NAME1 entries in the Word document but I want to have multiple searches for example;
.Text = "NAME1" & "NAME2"
.Replacement.Text = Range("C2") & Range("C3")
So that it will replace NAME1 and 2 with what is in C2 and C3. I want to do about a hundred of these.
Also I would like some assistance on how to modify this macro so the user cannot interact with it and once the changes are complete it Prints and Closes the word document.
Many thanks.