Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-27-2013, 12:46 PM
Cosmo Cosmo is offline TextFields disappear during mail merge Windows Vista TextFields disappear during mail merge Office 2007
Competent Performer
TextFields disappear during mail merge
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default TextFields disappear during mail merge

I have a mail merge document which has a table that has cells for fields in the merge, as well as cells holding form fields (CheckBoxes & TextFields) which need to be filled in after the merge. The merge operation is being mostly scripted, and after the merge is completed, the document is protected for form fields.

So far, everything is working properly, except the TextFields in the table are removed during the merge, but the CheckBoxes are intact. Is there a reason that the CheckBoxes work, but the TextFields don't? Is there something that can be done to keep the TextFields from being removed?

If not, is there anything I can do during the 'MailMergeAfterRecordMerge' event to replace those TextFields? This document has a Cover Page which I am moving to a temporary document before the merge, and restoring afterwards. Do I need to use a similar method for each record to restore the form field section during the merge ?
Reply With Quote
  #2  
Old 09-29-2013, 08:22 PM
macropod's Avatar
macropod macropod is offline TextFields disappear during mail merge Windows 7 32bit TextFields disappear during mail merge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Basically, mailmerge is incompatible with formfields. See: http://support.microsoft.com/kb/286841
For a workaround, see: http://www.gmayor.com/Form_Fields_and_Mail_Merge.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-30-2013, 07:51 AM
Cosmo Cosmo is offline TextFields disappear during mail merge Windows Vista TextFields disappear during mail merge Office 2007
Competent Performer
TextFields disappear during mail merge
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Basically, mailmerge is incompatible with formfields. See: http://support.microsoft.com/kb/286841
For a workaround, see: http://www.gmayor.com/Form_Fields_and_Mail_Merge.htm
Thanks, I had suspected as much. I just found it odd that the text fields are removed, but other form fields are retained. I'm looking into the links you provided, to see if they will solve the issues I'm having.

I haven't had the chance to test moving the section of the mail merge that has form fields to a separate document yet, I am wondering if you know whether or not the Text Field form fields will be stripped out if I add that section back in during the MailMergeAfterRecordMerge event? Or do I need to add that section, keep track of each range as it's added, then restore the form fields to those ranges after the merge is completed?

Another incompatibility I came across is that the form fields lose their values when the Mail Merge reaches the 'Select Recipients' step, so I have to store and reset their values at the appropriate times. I believe I have this partially working. I did a test using one of the form fields and resetting it's value after the merge, and that seemed to work, so I created a function to loop through all form fields on the cover page and reset their values. I believe this will do what I want, although I still need to investigate to make sure it works when it needs to.
Reply With Quote
  #4  
Old 09-30-2013, 01:39 PM
macropod's Avatar
macropod macropod is offline TextFields disappear during mail merge Windows 7 32bit TextFields disappear during mail merge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Instead of trying to re-insert the formfields as each record is generated, via the MailMergeAfterRecordMerge event, you'd do better to wait until the merge has completed then re-insert the formfields for all records in a single pass - all you need is a placeholder for that, as the article in the link indicates.

As for values being lost, what you're doing suggests the formfields are not required after the merge - only their results. In that case, you could leave the formfields in the mailmerge main document but use a macro to convert them to their results before executing the merge. Just don't re-save the mailmerge main document after running the macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-01-2013, 05:48 AM
Cosmo Cosmo is offline TextFields disappear during mail merge Windows Vista TextFields disappear during mail merge Office 2007
Competent Performer
TextFields disappear during mail merge
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Instead of trying to re-insert the formfields as each record is generated, via the MailMergeAfterRecordMerge event, you'd do better to wait until the merge has completed then re-insert the formfields for all records in a single pass - all you need is a placeholder for that, as the article in the link indicates.
Thanks again, I'm going to spend some time looking into this today. I wasn't sure if there was a way to access a specific section for each record of the merge once it was completed (I haven't done much VBA in Word before), and figured that appending an existing range to the end of the document after each record merge would be an easy way to accomplish this task.
Quote:
Originally Posted by macropod View Post
As for values being lost, what you're doing suggests the formfields are not required after the merge - only their results. In that case, you could leave the formfields in the mailmerge main document but use a macro to convert them to their results before executing the merge. Just don't re-save the mailmerge main document after running the macro.
The problem is that the values are cleared when the data source is selected, and my goal is to allow the user to save the document once it has been set up (before the merge is run) so that they have the option to just run or re-run the merge when they need to. This would make their template uneditable once they set up the data source. Also, I'd like to leave the ability to edit these fields in the document after the merge as well.

One other issue that has come up is how I am activating the macro. Once the document is protected for the form fields, the Macros are greyed out (and I didn't want to have the user run them through the menu anyway), so I tried a command button (which, unless I'm doing something wrong, only worked until the document was closed and reopened), and using a MacroButton hyperlink. This seems to work, but requires double-clicking the link to run. Plus, the first click shifts the page view which I find not user-friendly. Is there a better option to give the user a way to run the macro?

Also, I want to reset all of the properties for those fields that are removed. From what I see, that article only creates a new form Field, and sets it's name and text. I need to set it's maximum length, as well as type (number/date/etc.). I don't see anywhere in the language help files that allows me to set these; they are either read only (Format, Type) or non-existant (Maximum Length).

Edit: after some contemplation, I think the way to go might be to use the method in that article, but instead of creating a new form field, locate the form field in the original document, then copy it's range to the merged document.
Reply With Quote
  #6  
Old 10-01-2013, 12:26 PM
Cosmo Cosmo is offline TextFields disappear during mail merge Windows Vista TextFields disappear during mail merge Office 2007
Competent Performer
TextFields disappear during mail merge
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by Cosmo View Post
Edit: after some contemplation, I think the way to go might be to use the method in that article, but instead of creating a new form field, locate the form field in the original document, then copy it's range to the merged document.
After some more contemplation (and a few tests with varied success), I think I have come up with the proper game plan:

Before merge starts:
Store original document's 'Saved' state
Duplicate entire original document to a temp 'reference' document (hidden).
Delete Cover page from original document
Convert the textFields to placeholders in original document

After merge completes:
Add cover page from reference document (bookmark) to merged document
Restore text fields in merged document from reference document
Reset contents of original document to contents of reference document
Reset original document's 'Saved' state
Close/delete reference document
Reply With Quote
  #7  
Old 10-01-2013, 05:37 PM
macropod's Avatar
macropod macropod is offline TextFields disappear during mail merge Windows 7 32bit TextFields disappear during mail merge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Cosmo View Post
The problem is that the values are cleared when the data source is selected, and my goal is to allow the user to save the document once it has been set up (before the merge is run) so that they have the option to just run or re-run the merge when they need to.
Since you're using Office 2007, is there a reason for not using Content Controls instead of Formfields? You wouldn't have any of these issues with Content Controls - and the document doesn't even need to be protected for them to work. I know Office 2007 doesn't support checkbox Content Controls, but that can easily be worked around with a dropdown Content Control.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 10-02-2013, 05:37 AM
Cosmo Cosmo is offline TextFields disappear during mail merge Windows Vista TextFields disappear during mail merge Office 2007
Competent Performer
TextFields disappear during mail merge
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Since you're using Office 2007, is there a reason for not using Content Controls instead of Formfields? You wouldn't have any of these issues with Content Controls - and the document doesn't even need to be protected for them to work. I know Office 2007 doesn't support checkbox Content Controls, but that can easily be worked around with a dropdown Content Control.
I'm not familiar with Content controls (I don't use Word often); I'll look into this. Also, I may be using Office 2007, but I don't have control over the final user's version, and would like it to be compatible back to 2003 if possible. Are they compatible with versions that old?

These forms have gone through legal reviews, so they usually can't be redesigned. I have to recreate them as they originally were created, so I can't change the checkboxes.

Thanks again for all of your assistance, I'm going to try to get through setting up the code today so I'll hopefully know if it is working the way I need it to soon, or if any other issues crop up that I wasn't anticipating.
Reply With Quote
  #9  
Old 10-02-2013, 05:50 AM
macropod's Avatar
macropod macropod is offline TextFields disappear during mail merge Windows 7 32bit TextFields disappear during mail merge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Content controls are not compatible with Word versions prior to 2007. In versions earlier than that, they are converted to their results.

As for the checkboxes, I'm not suggesting a change in the document design - just in the way the checkboxes are checked/unchecked. Be that as it may, if you can't use content controls it's a moot point.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 10-02-2013, 08:42 AM
Cosmo Cosmo is offline TextFields disappear during mail merge Windows Vista TextFields disappear during mail merge Office 2007
Competent Performer
TextFields disappear during mail merge
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Content controls are not compatible with Word versions prior to 2007. In versions earlier than that, they are converted to their results.

As for the checkboxes, I'm not suggesting a change in the document design - just in the way the checkboxes are checked/unchecked. Be that as it may, if you can't use content controls it's a moot point.
Ok, I thought you meant to use a dropdown (Combobox) to select from instead of several checkboxes. Have only looked into the Content Controls briefly so far, when I get time, I'll investigate more thoroughly.

I finished the coding, and it looks like everything is working properly! I still have the issue of how to best activate the macro (the MacroButton I added seems to require double clicking; I've thought about adding a button to the ribbon, or a menu item in 2003, but haven't looked into that just yet) and seeing if I can find a way to alert the user if their security settings are high enough to suppress all macros. I may put everything on an extra 'instructions' page before the cover page. There may be a few other small details I need to work out, but the basic functionallity is there.

I also need to get our company, or our client, to purchase a digital certificate so that I can digitally sign the macros. Never had to do this before, only tested with a self-sign certificate, which I can't distribute. Hopefully, this should help solve the security issues.

I can't thank you enough for your help, I'd still be tearing my hair out at this point without it.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
TextFields disappear during mail merge merge fields disappear in merge doc but prints mdod Word 1 07-19-2013 06:33 PM
Mail Merge Duplication of address on merge RICKY Mail Merge 1 09-26-2012 03:14 PM
TextFields disappear during mail merge Conditional merge fields in mail merge Aude Mail Merge 1 01-06-2012 07:38 PM
TextFields disappear during mail merge Color in textfields darker/more intense than object paulie_k PowerPoint 3 12-13-2011 09:21 AM
TextFields disappear during mail merge Saving INDV mail merges During the mail merge sedain121 Mail Merge 2 10-04-2011 07:52 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:01 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