PDA

View Full Version : Need macro to change 1000's of word documents header/footer with graphic and diff 1st



pcgirl
03-18-2014, 06:14 AM
Frustration and bamboozlement!
:crying: :banghead:
Our business unit has had rebadging done (logo etc) and I've been asked to update the old templates with new templates. At the very minimum, I'm going to have to update 2,000 files. :eek: We also have literally 8,000 files with old obsolete links to non-existent logos from many years ago that also need fixing. (you can imagine the trouble they cause as they don't time out for ages).

I have tried to generate a new template and use that in a regular type of "replace" macro, and have even played with a couple of VBA scripts, but nothing is working correctly.

I am hoping that some mighty vba scripting genius can help me out with a nice simple script that - Opens a file - replaces the old header and foot with the graphics from another file and applies a template - then closes the files with the same name - then opens the next file in a folder.

I'm happy to type in the folder location in the vba script, but I have never coded script myself and have only a very basic understanding of it.

Please - can anyone help me out? We are also moving in July of this year and will need to do it all again.. well for part of the footer, anyway.

Thanks. :)

Mandy

macropod
03-19-2014, 11:58 PM
Hi Mandy,

Are you looking to replace the entire header & footer, or just the graphics? If the latter, how many graphics are there in the header and in the footer?

Also, a Word document has three header objects, a 'first page' header, used only when your document has a 'different first page' setup and an 'even page' header, used only when your document has a 'different odd and even' setup, plus the default header. Furthermore, in a multi-Section document, every Section has all three attributes. So, you'll need to tell us exactly what portions of these templates need modifying.

The idea that you might have some 2000 templates to update seems rather excessive. I'm also not sure where the 8000 files come into play. Surely you don't want to compromise the legitimacy of your business's past correspondence by replacing what is a true representation of the documents at that time with anachronistic header/footer content from today?! Indeed, your comment about these files having "obsolete links to non-existent logos from many years ago" suggests the original templates had those links, in which case, the files can be restored by the simple expedient of re-creating the content to which they were linked. At most you might then need to update the link paths.

pcgirl
03-20-2014, 06:55 AM
Hi Paul,

1 - The entire Footer and header. I actually found a script that does this and have updated all 145 templates. There were 3 graphics in total.

2 - I'm aware of the multi header sections and the script allowed that to be incorporated. It basically just pasted the graphics, style and placement of the graphics. IT is going to incorporate the letterhead style/template into word, which will correct the formatting.

3 - As the system is a government server, and the business unit has moved servers many times over the years, recreating the links is not possible, as the loading of the page causes the computer to lock up while is searches a non-existent path and IT refused to even look at the templates, as they are "wild". The path that the header used to be located at, is no longer on the network.

The legal professionals use these templates as content only. The actual final document is safely stored in a database that leaves the integrity of the document intact. I would have to manually correct the scripting in the the original files that date back up to 10 years, which would be very time consuming and frustrating. I have also "fixed" this issue by using the same script, but pasting empty characters in the header. :)

I work in a government legal office where there have been very clever professionals over the years. They have left behind legacies of correspondence with very clever and complex wording in various documents - but they had no concept of how to save the files correctly. These documents are used by the current legal officers when sending out their response letters. My job was to fix the broken files/links, update current "templates/drafts/samples" with the new letter head, contact IT to have all the word default templates updated and to update templates within the database software (145 of them - yes ALL in use). Existing final letters are stored in a database. We send out approximately 1000 letters a month and the current database software has been in place since 2009. There are 17,000 docs in the general network drive that have been saved - so you can imagine how many there are in the database.

So, basically, I have managed to find my answers myself and "fixed" my problems so that future employees in my position dont' have the same issues. Next week I week out the obsolete ones and clean the rest of it up.:whip

Thanks anyway for your input. :friends:

Mandy

macropod
03-20-2014, 03:13 PM
Hi Mandy,

Regarding the delays with files looking for templates on non-existent servers, you may be interested in the macro I wrote to fix those, at: http://www.eileenslounge.com/viewtopic.php?p=107602

A workaround would be for your IT people to fire up a virtual server with the same name and an empty share so you can store a template there. The template doesn't have to be the same as the original one; it just needs the same name & path. Word will then quite happily open the documents without the extended delays.