Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multifile Find and Replace 2

Status
Not open for further replies.

MeGustaXL

Technical User
Aug 6, 2003
1,055
GB
Hi There,

I've got 27 documents, all relating to the same project, all treating different subjects, but all based on the same basic document.

This base document is not a Template, but I need to make the same set of changes throughout the whole lot, e.g. Product Name changed, Contract Number updating, Change of Project Manager, etc.

Is there a way I can Group all the documents and do a Batch Find and Replace on all of them? This would probaly save me DAYS of work [ponder]

MS Word 2003 is the beast I'm using.

Thanks in advance for ANY help or suggestions!

Chris

Someday I'll know what I'm donig...damn!

 
Are you comfortable working with VBA? Forgive me if it's a silly question, b/c I don't particularly remember whether you've ever said much about that or not.

If you are, then that'd definitely be the way to go.

You could use the Dir() function in VBA, as I saw PHV mention in a thread a while back, but I don't remember the exact thread right off - was one where I offered another solution.

My solution was using the Scripting.FileSystemObject, which requires adding a reference. You can see both mentions here:
thread705-1640782

I personally really like the FileSystemObject for looping through files.

Basically, what I would do is:
[ol][li]Make sure all the files are in the same folder (if possible)[/li]
[li]Use VBA to loop through all the files[/li]
[li]At each file, do a find/replace for EACH text bit you want to find and replace... assuming they are straight forward enough that you wouldn't end up changing unwanted spots in the documents. If that isn't possible, then it might get a little more complicated, but I'd think still possible.[/li]
[li][/li]

Here's a reference online of using the Dir() function if you'd rather give that a try as well:

And of course, you can find it in the VBA help file.

Another method would be to record Record a Macro in Word, save it in your Personal.XLS file when asked, and then once finished changing one document, use that new procedure to do the same to all other documents you want to chnage... you could manually open them all, or you could do this:

1. Add the loop to the code to where you loop through the documents, and basically all or most of the recorded code will go inside your loop.
2. You'd need to create a variable for the files (Word Docs) that would refer to each document that is controlled or opened, so you may need to look up some references to the Word Application Object and its sub-objects.
 
Thanks kjv1611 [thumbsup]

All a little bit beyond me, I'm afraid, so I went with "Word Search and Replace 2.40" which is a free download Word document with a suitable macro in it, and it does just what I want it to [rockband]

I downloaded it from here:

Chris

Someday I'll know what I'm donig...damn!
 
Yeah, pretty cool. Basically, somebody put the idea together and made it available to everybody. Thanks for sharing the link!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top