PDA

View Full Version : Help with VBA syntax reading from .txt and editing .doc file



sindre182
09-07-2011, 02:07 AM
I have a problem with some vba programming, and unfortunately I am not to known with vba syntax. Therefore I would be extremely grateful if someone could please help me.
My problem is the following; I want to make a vba script in notepad that first reads three lines in a my_text.txt file. The first line will be a destination on the hard drive, the second line the name of the my_document.doc file I want to edit, and the third line is a project number. I guess all of these should be saved as strings in variables in vba.
Then in the rest of the script I want to edit my_document.doc file at the destination given in my_text.txt file. I just want the script to scan thru my_document.doc file and find where it says “xxx” or “xxxx” and change it to the project number given in my_text.txt file. This includes both footers, headers, tables and all other possible places in the document. Then at last the program should output the edited document and replace the old one.
The word document is of type “Microsoft Office Word 97 – 2003”.
Is this possible to do in vba?