SiobhanO


I have been asked to "clean up" existing Word templates that have VBA code in them. Basically what I need to do is to remove the old code that is currently in the ThisDocument class module of the template and replace it with the new code.

I've exported the "good" code to a .bas file and I have worked out how to import it back into the Word Template but the only problem I have is that I am importing it as a new module and the original code for the template is stored in the ThisDocument module. I don't know how to either clear the ThisDocument module programmatically (using VBA) or how to replace the contents of it with the "good" code.

There are hundreds and hundreds of these templates and I am looking for the quickest and easiest solution as I am only new to the whole VBA world.

Any help greatly appreciated.

Thanks in advance.

SIobhan




Re: Help Deploying VBA changes across hundreds of Word Temlates

Derek Smyth


Hi,

Thats a nasty one mate, but it could be possible. Your going to need to write something that selects the word template, or ideally a group of templates, and then opens each one and modifies the VBAProject.

Have a look at this excellent article

http://www.cpearson.com/excel/vbe.htm

It gives examples of how you can write VBA code that modifies VBA code. Select a group of templates that you want to modify the same way, open each template, modify it's VBA to whatever you need, and then save it. Hopefully that should do the trick.