Question
wrote this macros for word to do a find replace on multiple files. trying to do it so it : 1. Can do do what
wrote this macros for word to do a find replace on multiple files. trying to do it so it :
1. Can do do what it already does(Find and replace on multiple files)
AND
2. also find and replace multiple values at the same time.
I want to run this on word microsoft.
Sub GlobalFindAndReplace() 'Set Vairables Dim WordToFind As String Dim WordToReplace As String 'Set word to find as input from user WordToFind = InputBox("What is the word you wish to find and replace?", "Word to find") 'Check that word to find is not blank If WordToFind = "" Then Exit Sub 'Set word to replace as input from user WordToReplace = InputBox("What is the word you wish to use as replacement?", "Word to find") 'Check that word to find is not blank If WordToReplace = "" Then Exit Sub 'Loop Every Open Document For Each Doc In Application.Documents Doc.Content.Select With Selection.Find .Forward = True .Wrap = wdFindStop .Text = WordToFind .Execute End With With Selection.Find .ClearFormatting .Replacement.ClearFormatting .Text = WordToFind .Replacement.Text = WordToReplace .Forward = True .Wrap = wdFindContinue .Format = False 'Set the below to true or false as per your requirements .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False 'Set the above to true or false as per yout requirements On Error Resume Next .Execute Replace:=wdReplaceAll End With Next 'Display a message box to let the user know the task has been completed MsgBox "Completed" End Sub
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started