I need a macro for batch word find and replacing (.docx & .rtf)
Am having more than 40 documents in a folder and need to find and replace the multiple strings manually can anyone help me in this regards am very thankful to them..
Macro should ask for the source folder and loop the macro to all the document’s and save in the same document.
Message pop as “replaced successfully and colored in red color”.
Am having macro that will replacing multiple strings on individual files but I want to do this as batch.
Please find the below.
MACRO FOR BATCH WORD FIND AND REPLACING
Code
Sub CHINESE_REPL()
'
' CHINESE Macro
'
'
Dim row As Integer
Dim aa(1 To 100) As String
Dim bb(1 To 100) As String
row = 1
aa(1) = "project"
bb(1) = "Items"
aa(2) = "This reporting period"
bb(2) = "\\\Current reporting period"
aa(3) = "last year"
bb(3) = "Previous period"
aa(4) = "Increase or decrease (%)"
bb(4) = "Increase or decrease (%)"
aa(5) = "Total operating income"
bb(5) = "Total operating income"
aa(6) = "operating profit"
bb(6) = "Operating profit"
aa(7) = "The total profit"
bb(7) = "Total profit"
While row <= 42
Selection.find.ClearFormatting
Selection.find.Replacement.ClearFormatting
Selection.find.Replacement.Font.Bold = True
Selection.find.Replacement.Font.Color = wdColorYellow
With Selection.find
.Text = aa(row)
.Replacement.Text = bb(row)
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.find.Execute Replace:=wdReplaceAll
row = row + 1
Wend
End Sub
Display More