Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-06-2014, 06:58 AM
Cosmo Cosmo is offline Creating a new document from a template screws up fields! Windows Vista Creating a new document from a template screws up fields! Office 2007
Competent Performer
Creating a new document from a template screws up fields!
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 08-06-2014, 11:03 AM
Charles Kenyon Charles Kenyon is offline Creating a new document from a template screws up fields! Windows 7 64bit Creating a new document from a template screws up fields! Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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?
Reply With Quote
  #3  
Old 08-06-2014, 11:50 AM
Cosmo Cosmo is offline Creating a new document from a template screws up fields! Windows Vista Creating a new document from a template screws up fields! Office 2007
Competent Performer
Creating a new document from a template screws up fields!
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
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?
Opening the template directly in Word opens correctly.

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.
Reply With Quote
  #4  
Old 08-06-2014, 11:59 AM
Cosmo Cosmo is offline Creating a new document from a template screws up fields! Windows Vista Creating a new document from a template screws up fields! Office 2007
Competent Performer
Creating a new document from a template screws up fields!
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

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.
Reply With Quote
  #5  
Old 08-06-2014, 12:30 PM
Cosmo Cosmo is offline Creating a new document from a template screws up fields! Windows Vista Creating a new document from a template screws up fields! Office 2007
Competent Performer
Creating a new document from a template screws up fields!
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 08-06-2014, 02:40 PM
Charles Kenyon Charles Kenyon is offline Creating a new document from a template screws up fields! Windows 7 64bit Creating a new document from a template screws up fields! Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Ahh. We've all been there.
Repeating Data (Populating Multiple Like Fields)
Reply With Quote
  #7  
Old 08-07-2014, 05:16 AM
Cosmo Cosmo is offline Creating a new document from a template screws up fields! Windows Vista Creating a new document from a template screws up fields! Office 2007
Competent Performer
Creating a new document from a template screws up fields!
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
Yes, but while some occasionally visit, others of us seem to have a more permanent residence.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a new document from a template screws up fields! When creating new template from established template macros getting lost. TechEd Word 3 06-09-2014 07:22 PM
Creating a new document from a template screws up fields! 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft