help: how to automate "find and replace" in word 2003 using macro

L

low

HI:

Working on a word 2003 doc. I want to find in that document,
occurrence of every Chinese word on a list I prepared, replace them
one by one with their English corresponding word on the same list (on
the same list as the Chinese words, side by side).

I've copied pasted the following code from the macro editor in Word:

Sub test1()
'
' test1 Macro

'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "$BCOJ}(B" /* how to replace this
"hard coded " value with a variable, taken from */
.Replacement.Text = "endroit " /* a file, with a given
address, say "C:\bilingualList.txt" ???*/
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Can someone tell me how to code the 2 commented line so that the macro
goes to the file, take the work one by one from the list and change
them?

I have no programing experience with VB, but do have some experience
with C and java. thanks.
 
L

low

Create your list and use the AddIn provided here:

http://gregmaxey.mvps.org/VBA_Find_And_Replace.htm












--
Greg Maxey - Word MVP

My web sitehttp://gregmaxey.mvps.org
Word MVP web sitehttp://word.mvps.org- Hide quoted text -

- Show quoted text -

many thanks, went to your website and downloaded. it works fine, Since
I've some programming experience, my curiosity is not satisfied: how
it was achieved and what are the source code? Fortunately, from ur
site I've found the FAQ for biginners, I will dig into it. I just need
a handle to it.

thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top