Visual Basic

  1. Home
  2. Computing & Technology
  3. Visual Basic

VBA - The Word Working Partner - Part 3

By Dan Mabbutt, About.com

6 of 7

Automate Find and Replace Example - Page 4

Then, all you have to do is create a collection, array, file, or even a database of the find and replacement text strings and loop through all of them.

This complete code shown below does the trick using a fixed length array. This technique has some limitations, but it's simple and illustrates the point. This macro's worst remaining problem is that since the find and replace strings are hard coded in the text of the macro, the macro itself has to be updated to add or change them. This is definitely a poor coding technique. That's one reason why an external file or database might be a very good idea!

Explore Visual Basic

By Category

About.com Special Features

Visual Basic

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB 6
  5. Learn VBA
  6. VBA - The Word Working Partner - Part 3

©2009 About.com, a part of The New York Times Company.

All rights reserved.