Multiple Find and Replace in MS Word Using Macro

Nowadays, I am working with a lot of Unicode text in MS-Word. In documents that I handle, all pieces of the text invariably need editing. And that’s what I do! But there are some commonly occurring mistakes which I have to repeatedly correcting in various documents.

So, I thought it would be great if I could run several find and replace commands in one go. I often use Find and Replace facility of MS Word. Now the question was how to do multiple find and replace operations on one click.

Well, the answer has to involve a macro! Several tasks can be executed in any MS Word document by the way of macros.

A macro is a set of several commands put together in a particular sequence. All you need is to write a macro and then keep running it on the target documents. For multiple find and replace, you can use a module like given below (I found it on Internet):

Sub MultiReplace()
Dim StrOld As String, StrNew As String
Dim RngFind As Range, RngTxt As Range, i As Long
StrOld = "the,quick,brown,fox"
StrNew = "The,Quick,Brown,Fox"
Set RngTxt = Selection.Range
For i = 0 To UBound(Split(StrOld, ","))
  Set RngFind = RngTxt.Duplicate
  With RngFind.Find
    .Text = Split(StrOld, ",")(i)
    .Replacement.Text = Split(StrNew, ",")(i)
    .Format = False
    .MatchWholeWord = True
    .MatchAllWordForms = False
    .MatchWildcards = False
    .Execute Replace:=wdReplaceAll
  End With
End Sub

In this macro program, the comma separated values in StrOld are the items to be replaced. Each item in this list will be replaced by the corresponding value given in StrNew string. Needless to say, both the strings should have equal number of values and obviously the sequence of the values does matter.

You can write this macro by going in the Visual Basic Editor of Microsoft Word.

I keep on writing articles about time saving MS-Word tips. Do subscribe my blog and keep on receiving great tips that will help you achieve greater productivity at work place.

I hope this was useful for you. Please do let me know if you have any questions on this topic. Thank you for using TechWelkin!

14 thoughts on “Multiple Find and Replace in MS Word Using Macro”

  1. Hi,

    I would like to highlight special instances of text in a Word document by using wildcards. I’ve searched widely, but my particular circumstances don’t appear to be catered for.

    I’d like to transform ALL instances of [word [timestamp]] in a document, e.g. [inaudible [12:34]] so that the square brackets and all the contents are highlighted in yellow in one press, after set-up.

    I’ve tried the dialog box for find and replace / wildcards, etc. but cannot find a way through to achieving this with what would ultimately be one button press !

    I thought I had it at one point when I set it up, pressed enter, and all my examples were highlighted in yellow…

    …BUT the original text was lost, and replaced with hundreds of[*]s. Hope someone can help because the time saved compared to doing this manually would be enormous,

    Many thanks, Paul

  2. how to use macro for alternate find n replace, i want to replace an image present at regular interval in the document and there are other images too, so i want to delete/replace that specific image..
    i can upload the doc if u need.

  3. I have n no of word documents and I want to do format with below points please help me how to do this in one click.

    1)Remove red and green lines as per the specification.
    2)Each and every new paragraph use indentation 0.5 and first alphabet superscript.
    3)Give double space after full stop (.) question mark (?) and exclamatory mark (!) at anywhere dot is there double space required.
    4)One space before opening bracket & after closing bracket and inverted comma
    5)After comma one space.
    6)Double hyphen (–) or big hyphen (─) before and after one space.
    7)Give one space after colon (:) and semi colon (;) but not end of the line, statement and paragraph, Single hyphen (-) and Underscore (_) no space.
    8)Remove the Bold, Italic & Underline.
    9)If any words having double alphabets then will be expanded 0.5 pt & scale 50%.
    10)Each and every Numeric used Super Script & Sub Script respectively.

  4. i want to find and replace multiple words in a word document by using this step but i have some syntax error. can u help me?

  5. Thank you. I found the article very helpful.
    Please what command or formula can I use to call up two paragraphs in a document with each having 5 lines of text?

  6. I found a great software that does this with ease for Word/Excel documents. Probably works for other document types also. It is called Useful File Utilities (by Replsoft) + their Batch Replacer plugin. The light version of UFU is freeware. The plugin is also freeware and as far as I know has no limitations.

  7. Thanks for the piece of code. Would like to make the replaced words have a red color formatting so that I can check that only correct words were properly replaced.

  8. I want to change address in the header of my MS-Word document. I have more than 25 .doc files, in each of these MS-Word files I have to change the address. Let me know how I can change the address.

  9. Many thanks for the neat piece of code. I have modified and use it to create paragraphs with blanks for English language students to fill-in with suitable words.

  10. Hi,

    I have a 20 page doc, where i need to enter the address, phone number and name at different locations. And these three things will change for every new customer.

    Can you suggest some technique or macro code for the same? Something like, if i enter the address at one place in the doc, then it gets automatically filled at other locations too.


    1. Mail Merge feature of MS Word can solve your problem. But you would need to have all structured information (like name, email, address etc.) in an Excel file or MS Access database.

Leave a Comment

Your email address will not be published. Required fields are marked *