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

VBA - The Word Working Partner - Part 3

By Dan Mabbutt, About.com

3 of 7

Automate Find and Replace - A VBA Example from an About Visual Basic Reader

Paul Dalton, an attorney at a law firm, wrote that he needed a better way to clean up text spacing in documents. Using the Word macro recorder tool, Paul had already created a very extensive macro that found every instance of "X" and replaced each with "Y", such as changing one space at the end of a sentence to two spaces, over and over. In fact, that was the problem. The macro had become so large (well over 2000 lines) that it was getting out of hand.

Paul wanted a macro that would do the same thing with looping logic but he couldn't quite figure it out.

Paul's original recorded macro was similar to the code on the next page ...

Explore Visual Basic
By Category
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  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.