Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago