Link to home
Start Free TrialLog in
Avatar of mrigank
mrigank

asked on

Replace a string in a word file

Hi all,

I have word document. I have a particular string in that document. I want to replace that string with another given string using Visual Basic. My original file has some tables and some images which should be modified. I only have to replace a string with another one.

Can you help me out.
If you can provide the source code, it would really help.

It is urgent.

thanks
mrigank
ASKER CERTIFIED SOLUTION
Avatar of Shahid Thaika
Shahid Thaika
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I forgot to add the following in the second last line before 'End Sub'

WApp.Quit

But it won't make much difference if you don't include it. You just have to manually close word :).
Oops, one more mistake found (Silly of me). The code should be 'WApp.Documents.Close True' after the else part of the If statement. Not 'True'.
Dear mrigank, does the code work or needs any change?