PDA

View Full Version : How to find and replace multiple words at one time



fann80
08-14-2010, 08:03 PM
I have two files: document.doc and replacelist.xls

<document.doc>
Not for the first time, an argument had broken out over breakfast at number four, Privet Drive. Mr. Vernon Dursley had been woken in the early hours of the morning by a loud, hooting noise from his nephew Harry's room.
"Third time this week!" he roared across the table. "If you can't control that owl, it'll have to go!"
Harry tried, yet again, to explain.
"She's bored," he said. "She's used to flying around outside. If I could just let her out at night -"
"Do I look stupid?" snarled Uncle Vernon, a bit of fried egg dangling from his bushy mustache. "I know what'll happen if that owl's let out."
He exchanged dark looks with his wife, Petunia.


<replacelist.xls>
---A--------- B
1 isn't------is not
2 won't-----will not
3 it'll -------it will
4 she's-----she is
5 She's-----She is
6 Harry's----his
.... ....


****
Working on the word file(document.doc), I'd like to find words from A column of replacelist.xls and replace them with words in B column.

That is to say, the word file will be changed like this

<document.doc>
Not for the first time, an argument had broken out over breakfast at number four, Privet Drive. Mr. Vernon Dursley had been woken in the early hours of the morning by a loud, hooting noise from his nephew his room.
"Third time this week!" he roared across the table. "If you can't control that owl, it will have to go!"
Harry tried, yet again, to explain.
"She is bored," he said. "She is used to flying around outside. If I could just let her out at night -"
"Do I look stupid?" snarled Uncle Vernon, a bit of fried egg dangling from his bushy mustache. "I know what'll happen if that owl's let out."
He exchanged dark looks with his wife, Petunia.



This means:
"She's"(in A column) has been replaced with "She is"(in B column)
"Harry's" has been replaced with "his"
"it'll" has been replaced with "it will".
"isn't", "won't", and "she's" hasn't been replaced, because they are not in the doc file.

Search options:
Match case: False
Find whole words only: True

Thank you very much in advance.

gmaxey
08-14-2010, 10:32 PM
You can use my AddIn: http://gregmaxey.mvps.org/VBA_Find_And_Replace.htm

using a Word find and replace list (vice Excel List).