#1
|
|||
|
|||
Displaying FORMTEXT fields when merge fields are empty or null
I have a merge document (Word 2013) that I want to distribute to customers and have them fill in the missing information. The merge document populates fields from our database but where we have missing entries, in the mobile phone number for instance, I want a formtext field to display, prompting action from the customer to complete. I have tried using an IF statement: { IF { MERGEFIELD "Mobile Phone" } = "" { FORMTEXT } { MERGEFIELD "Mobile Phone"} } As you might expect, if "Mobile Phone" has data, then it is displayed. But if the field is empty, then nothing is displayed. Other formtext fields not embedded within merge fields display correctly. How can I display the formtext field conditionally? |
#2
|
||||
|
||||
You can't use formfields in a mailmerge document - they get deleted when the merge executes. However, you could insert all your mergefields into Rich Text Content Controls. That way, without the need to IF tests, the Content Controls will display either the merge results or the standard Content Control prompt. Plus the users will be able to edit any data that needs updating. When the forms are returned, you could then programmatically capture the data from the content controls to update the data source.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Hi Paul,
Thanks for your advice. This does sound like the way to go. Can you point me to a resource that illustrates how to link content controls to merge fields? Thanks, |
#4
|
||||
|
||||
No linking is required. Simply insert a Rich Text Content Control, then insert the mergefield into that.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
||||
|
||||
http://www.gmayor.com/ManyToOne.htm will allow you to combine mail merge and protected form fields in the same document. Note that this is not a true merge and your data must be in Excel format.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#6
|
|||
|
|||
Limited success
Hi,
I've had some limited success. I dropped a Rich Text Content Control into my document and then inserted a merge field into that. When I ran the merge the expected data was correctly populated. However I have a couple of issues. Elsewhere on the document I have plain formtext fields that display with a grey background, offering a visual clue to the recipient that data is required. Is there a way that I can make the Rich Text Content Control appear that way, particularly if it's empty? Also I noticed that when the document is protected with editing restrictions you can't fill in the RTCC like you can the formtext fields. Is there a workaround for that? Thanks very much for your assistance so far. |
#7
|
||||
|
||||
Firstly, you shouldn't mix content controls and formfields in the same document. They were not designed to work together and can exhibit some strange behaviour at times if you do so. The problem you're having may be part of that. Amongst other things, you can't tab out of a Content Control into a formfield. In any event, you can't tab out of a Rich Text Content Control (because they accept tabs as input); you need to use the mouse to select another control. Aside from such peculiarities, you should be able to edit a Rich Text Content Control in a document with filling-in-forms editing restrictions.
A document with filling-in-forms editing restrictions cannot be used for a mailmerge - you would have to apply those restrictions post-merge. In any event, Content Controls don't require any form of editing restrictions - the most you might need to do is to set their 'cannot be deleted' property. If you need to have some kind of shading, you could apply the 'no changes (read only)' restrictions - to each content control - post merge (you'd probably want to use a macro for that). If the Rich Text Content Control isn't populated by the mergefield, it will display its pale-grey default 'click here to enter text' prompt.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
merge formtext |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Empty Fields in MS Word | georgedy | Word | 1 | 12-21-2015 10:38 PM |
Macro to keep formatted form fields after mail merge or replace text with formatted form fields | jer85 | Word VBA | 2 | 04-05-2015 10:00 PM |
Using fields to test on empty ? | NobodysPerfect | Word | 4 | 10-11-2014 03:01 AM |
Word 2010 - DOCX File with fields -> PDF with fields | senglory | Word | 2 | 03-27-2012 10:10 AM |
Help with merge fields | Chris182 | Mail Merge | 3 | 12-04-2011 07:39 PM |