Editing a macro in a Word 2003 document using Word 2010 WITHOUT converting doc to 2010
Posted on 2012-08-29
I have a government client that is still using Word 2003. They have a few hundred Word 2003 documents containing macros that pull data from a database. I need to edit the macros but keep the documents as Word 2003.
When I open the 2003 version--without running the macros, which is important--I can't find the macro code in Visual Basic. If I open the 2003 version and run the macros--which destroys the letter content--then the macro code shows up in Visual Basic.
I can't use a template because these letters get individually loaded into a separate database and somehow pull XML data out of it. Every letter must contain the macro code.
In the body of the letter, there are placeholders for the data fields in the database, for example:
%CUSTOMER_CITY%, %CUSTOMER_STATE% %CUSTOMER_ZIP%
The macro contains the code to pull the data and replace the placeholders in the body of the document, like this:
Private Sub CustomerName()
ReplacePlaceHolder CUSTOMER_NAME, GetTemplateValue("CustomerName")
Because I am not attached to their real world system, when I run the macros, the macros replace the placeholders with blanks (which is actually correct in this scenario). But then I have to recreate all the darn placeholders.
I did not write this code and, frankly, I don't know how or why it works, but it does. I just need to add another field in the macro and in the letter.
What am I doing wrong?