Search Excel and copy result into word

A

Adie.Martin

Hi,

I'm a newbie to VBA programming and just trying to automate some tasks
for my Dad to save him some time. I have a word document and each of
these sentences are in a cell in excel (sheet1, column A, Starting at
cell 2 onwards). What I would like to do is create a program that will
take a sentence in word search for it in the above column and replace
it with the next in the next column over,

That is, if a sentence is found in A3 it would replace the sentence
with The text from B3.

Any help or advice on how to do this would be grateful.

Thaniks,
Adrian
 
E

Ed

Hi, Adrian. If you want to search the Word doc and do one sentence at a
time as you find one that needs replacing, I think you'd be better off
driving this from a Word macro. The way I would do it breaks down like
this:
-- Open Word doc and Excel workbook. These are the only Word and Excel
files open.
-- Make sure Excel workbook is open to the correct worksheet.
-- User selects a sentence in the Word doc to replace, and then runs the
macro.
The macro:
-- Sets objects to both files.
-- Set a bookmark at the selection.
-- Searches the Excel file for the selected text.
-- If found, replaces that with the desired text.

Then again, if you want to run the whole Word doc all at once, maybe an
Excel macro is better. I'd have it in the specific workbook that contains
you find/replace list. It would go like this:
-- Browse for Word doc and open.
-- Iterate through the Excel list, using those cell values to drive
Find/Replace in the Word doc.

The first way gives you control over replacing specific sentences; the
second way just runs through the entire doc. Which way sounds good to you?

Ed
 

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