PDA

View Full Version : Replace a word with a copy of a word



keiiya
01-16-2008, 01:08 PM
Hey,

I am just learning VBA and so I am trying to write bits of code. I seem to be having trouble with the pieces of code I am working on.

1. I have two word documents, A and B. I want to copy a few lines from document A and then use that string to seach document B to see if it contains it.

2. If it does, I want to replace the string found in document B with the one I copied from document A.

By string I just be a sentence that may be longer than one line.
By document I mean a Microsoft Word document (just to be clear, hehe).

I would appriecte any help/ideas. I know how to "copy and paste" words and "find and replace" words in one document. How ever I don't seem to be able to figure out how to replace a word with a paste or do the above between two document.

Keiiya

fumei
01-17-2008, 02:59 PM
Huh? I am not following the logic here.

1. I have two word documents, A and B. I want to copy a few lines from document A and then use that string to seach document B to see if it contains it.

2. If it does, I want to replace the string found in document B with the one I copied from document A.

Mmmm, that does not make any sense.

Say you get "Yadda" from Doc_A, and you search Doc_B to see if it contains..."Yadda". If it does, replace "Yadda" with......"Yadda".

Here is what you stated: "I want to replace the string found in document B with the one I copied from document A"

But they are, by definition, the SAME string. So what is the point of replacing it?

Once you explain that, the actual process to operate on string between document is not too difficult.