Ok no problem but this one which is updated again;
Sub Replacing()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Cursor = xlWait
Application.DisplayStatusBar = True
Application.StatusBar = "Generating DM Pack, please wait!"
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) = "ADD1"
sOutput(3) = "ADD2"
sOutput(4) = "ADD3"
sOutput(5) = "ADD4"
sOutput(6) = "ADD5"
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
MsgBox "DM Pack Created!" & vbCrLf & vbCrLf & "Please Check/Save/Print the Letter!"
'wrdApp.Quit False
Set wrdDoc = Nothing
Set wrdApp = Nothing
Application.Cursor = xlDefault
Application.StatusBar = "DM Pack Created!"
Application.StatusBar = False
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Works perfectly, what is the advantage of yours except cleaner code? It seems to run at the same speed.
Also I don't see in your code where Cell C is stated... You keep posting your code and I would use this but I see no difference as yet but im probably missing the obvious.
Bookmarks