#1
|
|||
|
|||
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 ? |
#2
|
||||
|
||||
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] |
#3
|
|||
|
|||
Quote:
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. |
#4
|
||||
|
||||
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] |
#5
|
|||
|
|||
Quote:
Quote:
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. |
#6
|
|||
|
|||
Quote:
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 |
#7
|
||||
|
||||
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] |
#8
|
|||
|
|||
Quote:
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. |
#9
|
||||
|
||||
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] |
#10
|
|||
|
|||
Quote:
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. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
Conditional merge fields in mail merge | Aude | Mail Merge | 1 | 01-06-2012 07:38 PM |
Color in textfields darker/more intense than object | paulie_k | PowerPoint | 3 | 12-13-2011 09:21 AM |
Saving INDV mail merges During the mail merge | sedain121 | Mail Merge | 2 | 10-04-2011 07:52 PM |