Log in

View Full Version : Find and Replace Macro HElp..



kolabear
01-06-2009, 12:52 AM
Dear Friends,

I have spent the entire day searching the forums but could not find a solution.

There are several "wordings" that I would need to change regularly and i use to do it manually with repeated Ctrl + H.. Thus could someone pls advice me on any macros available? I would need one that I could pre-define all the "wordings" and "the change" so hopefully in a click of a button, all the wordings in the text file will be changed..

PS, i would need to change characters in Chinese.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

The best i could find is one from Malcolm Smith, "dragondrop.com" but the version crashes and i would have to save and open another word file..
(pls see attachment)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<



If any one could help, greatly appreciated.. and many thanks in advance..


kolabear

lucas
01-06-2009, 09:02 AM
What if you run the find/replace from excel?

Try this, you will have to correct the path or move the file to that location.

in the script: C:\Temp\Invoice.doc"

then run the excel file. the words bookmark are not actually bookmarks the are just text strings.

TonyJollans
01-06-2009, 10:09 AM
The basic code is simple enough:

Finds = Array("Find first", _
"second", _
"and third")

Replaces = Array("Replace with this", _
"and that", _
"and the other")

For x = LBound(Finds) To UBound(Finds)

ActiveDocument.Content.Find.Execute _
FindText:=Finds(x), _
ReplaceWith:=Replaces(x), _
Replace:=wdReplaceAll

Next

You might need to do something special to get the Chinese in there but as you say they're all pre-defined that would be a one-off.