#1
|
|||
|
|||
Creating a new document from a template screws up fields!
I have come across a major issue with a VBA I am working on. I have been working on this project as a document file, but when I save it as a macro-enabled template (.dotm) , it screws up the fields (MergeFields) when creating a new document. Example, the header of the document has address fields:
«primary_name» «primary_address» «primary_city» ...etc. «primary_contactname»: but when the document is saved as a template file and a new document is created from that template, many of the fields are replaced by the user first name field (another MergeField used later in the document), and the city field has an extra opening tag (so it doesn't get replaced in the VBA code): «user_first_name» «user_first_name» ««primary_city» ...etc. «user_first_name»: I have tried deleting and replacing the fields, and the problem still persists. I even deleted the "user_first_name" field in the only place it existed in the document, and the fields are still replaced by it, even if it isn't in use anywhere else. Can anyone explain why this is happening? If I open the template via the file open in the Word application, then it opens fine, but if I open it by double clicking the file icon, the fields are wrong. How can this be fixed? |
#2
|
|||
|
|||
Can't explain without looking at it.
Some questions first: What happens when you open the template rather than create a new document based on it? What happens if you resave it, for now, as a .dotx template, leave Word and restart and use that to create a new documentL? |
#3
|
|||
|
|||
Quote:
I have tried resaving it in multiple formats (including .dot) all with the same results. I have restarted the Word application, but I haven't tried restarting the computer yet. |
#4
|
|||
|
|||
I think I figured it out - some of the values had been changed in the document, instead of editing the actual field names. So the field was the Username field, but was displayed with a different name. Don't know if I did that or if one of the other editors did.
|
#5
|
|||
|
|||
Yep, that was the problem. At some point when adding the fields to the updated document, I must have copied the field name into the field value itself in a couple instances instead of the field name.
Stupid user error. |
#6
|
|||
|
|||
Ahh. We've all been there.
Repeating Data (Populating Multiple Like Fields) |
#7
|
|||
|
|||
Quote:
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
When creating new template from established template macros getting lost. | TechEd | Word | 3 | 06-09-2014 07:22 PM |
Help with creating a Word document that is like a template | Nurse2014 | Word | 2 | 08-18-2013 01:22 PM |
Protected Fields in a document template | augurswelljan | Word | 3 | 05-01-2012 04:45 AM |
Creating a new template for existing document? | Stephen0352 | Word | 6 | 09-12-2011 09:00 AM |
Creating document from template but macros are still linked to template | webharvest | Word | 0 | 07-16-2011 09:34 AM |