I have updated the Macro and this is now the solution;
Sub Replacing()
Dim sFile As String
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim sInput(7) As String, sOutput(7) As String
sFile = "Pack"
Set wrdApp = New Word.Application
With wrdApp
.Visible = True
Set wrdDoc = .Documents.Open("C:\Users\Admin\Desktop\" + sFile + ".doc")
.Selection.Find.ClearFormatting
.Selection.Find.Replacement.ClearFormatting
sInput(0) = "C2"
sInput(1) = "C3"
sInput(2) = "C8"
sInput(3) = "C9"
sInput(4) = "C10"
sInput(5) = "C11"
sInput(6) = "C12"
sOutput(0) = "NAME1"
sOutput(1) = "NAME2"
sOutput(2) = "Address Line 1"
sOutput(3) = "Address Line 2"
sOutput(4) = "Address Line 3"
sOutput(5) = "Address Line 4"
sOutput(6) = "Address Line 5"
For i = 0 To UBound(sInput) - 1
With .Selection.Find
.Text = sOutput(i)
.Replacement.Text = Range(sInput(i))
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Next
End With
wrdDoc.PrintOut
wrdDoc.Close False
wrdApp.Quit False
Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub
Can you provide your feedback on this?
Bookmarks