Ok thanks again, but this is much different to what I posted and for a macro beginner makes no sense at all;
Who is Tom, Ken, Harry, ******
a(1, 1) = "****"
a(2, 1) = 2
a(1, 2) = "Harry"
a(2, 2) = 3
For i = 1 To 2
This i don't understand either.
I wanted the code I posted to be adjusted to support multiple find/replaces as a long loop;
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(ThisWorkbook.Path + "\" + sFile + ".doc")
End With
With wrdDoc.Content.Find
.Text = "NAME1"
.Replacement.Text = Range("C2").Text
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
End With
With wrdDoc.Content.Find
.Text = "NAME1"
.Replacement.Text = Range("C2").Text
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
With wrdDoc.Content.Find
.Text = "NAME2"
.Replacement.Text = Range("C3").Text
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
With wrdDoc.Content.Find
.Text = "Payment One"
.Replacement.Text = Range("G5").Text
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
'And so on until it has 50 of these.
wrdDoc.PrintOut
wrdDoc.Close False
wrdApp.Quit
End Sub
I understand what your trying to do, your new code is probably much better for me but I cannot understand it one but nor attempt to amend it.
If you can just adjust the code in this post I would be grateful.
Bookmarks