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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I globally replace text and images in Word?

Status
Not open for further replies.

asternstein

IS-IT--Management
Apr 22, 2002
13
GB
Using Word2003.
Have over 1,000 company word document templates with a footer containing the same text and images. Company has created a new letter template with new text and images for their footer. I need a method of globally replacing the old footer with the new footer in every document in as short a time as possible. Tried using WordPipe but it can't seem do it. Is there a software package to handle this or a utility that can be used?
 


Hi,

Have you tried recording a macro?

Skip,

[glasses] [red]Be advised:[/red]To be safe on the FOURTH, don't take a FIFTH on the THIRD, or...
You might not come FORTH on the FIFTH! [tongue]
 
To answer your question, the answer is, yes you can do this. Within Word, and without extra utilities.

Skip's suggestion is valid, and points to the route you need to take. You will have to run code to do this, but it is very do-able.

However, simply recording a macro, if you are not familiar with other aspects of VBA will not help (OK, a little bit) in your effort to do this efficiently. Recording a macro will give the needed code to do ONE replacement. To efficiently do a lot, you are going to need to use FileSystemObject - which is not available with macro recording. Unless of course I am totally off base and Skip will come back and tell me how to use FileSystemObject with the macro recorder. Which I would love to know, but I doubt this.

Record a macro that:
[ol]
[li]opens a source document - a file with the new header/footer[/li]
[li]opens an old document[/li]
[li]goes into the header of the old doc, and deletes it[/li]
[li]goes into the new doc and copies the header[/li]
[li]goes back into the old doc and pastes the header[/li]
[li]repeats for the footer[/li]
[/ol]

That approximately takes care of ONE conversion. To runs through LOTS, in however many folders, it is probably best to use, as stated, FileSystemObject. This allows direct access to the file system, and the files in it.

Organizing things would be best this way.

Separate the actual transfer (delete the old, copy and paste the new) into its own sub-routine. Create a main sub-routine that runs the transfering code for each file in a folder.

I suggest you record the basic macro, try it, see if it works, look up Help on FileSystemObject (you will need to add a reference to Microsoft Scripting Runtime) and see how far you get.

When you need some specific help, or if it gets too confusing, post in the VBA forum. Post your code, indicate exactly where you are having problems, and we can help you there.

There are, in fact, much better ways of dealing with headers and footers than what you can get recording a macro, but you should start there. Give it a try and post back if you need help. But try doing your own macro first.

But again, yes, you can do this.

Good luck.

Gerry
See my Paintings and Sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top