Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-26-2020, 07:08 AM
nmkhan3010 nmkhan3010 is offline Macro for batch word find and replacing .. Windows 10 Macro for batch word find and replacing .. Office 2016
Novice
Macro for batch word find and replacing ..
 
Join Date: Feb 2020
Posts: 2
nmkhan3010 is on a distinguished road
Default Macro for batch word find and replacing ..

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
Reply With Quote
  #2  
Old 02-26-2020, 04:11 PM
macropod's Avatar
macropod macropod is offline Macro for batch word find and replacing .. Windows 7 64bit Macro for batch word find and replacing .. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,040
macropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud of
Default

This has been addressed multiple times here. Do a search (e.g. for BulkFindReplace & UpdateDocuments).
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for batch process dita Word VBA 7 10-27-2019 09:15 PM
Macro for batch word find and replacing .. Batch applying a macro to remove Header and Footer using Batch Auto Addin Edszx Word VBA 2 05-27-2019 11:16 PM
If statement for find and replacing certain text dwirony Word VBA 6 10-24-2016 04:03 PM
Macro for batch word find and replacing .. Trying to create a macro to batch edit hyperlinks martinlest Excel Programming 5 01-09-2015 09:34 AM
Macro for replacing, copying and undoing. vthomeschoolmom Word VBA 1 12-05-2012 07:41 AM


All times are GMT -7. The time now is 09:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft