PDA

View Full Version : Mail merge - hide characters in field.



gregbartel
01-29-2013, 11:54 PM
Hello,
I have Word document with fields.
These fields will automatically fill in when I import recipients from xls file. One of these fields contains information of 10 digits. I would like to display only the last five characters. Is it possible that?

macropod
01-30-2013, 01:11 AM
Yes, simply use a MOD function on the mergefield:
{=MOD({={MERGEFIELD MyData}-1),10000)+1}

Note: The field brace pairs (ie '{ }') for the above example are created in the body of the document via Ctrl-F9 (Cmd-F9 on a Mac) - you can't simply type them or copy & paste them from this message.

gregbartel
01-30-2013, 08:00 AM
Yes, simply use a MOD function on the mergefield:
{=MOD({={MERGEFIELD MyData}-1),10000)+1}

Note: The field brace pairs (ie '{ }') for the above example are created in the body of the document via Ctrl-F9 (Cmd-F9 on a Mac) - you can't simply type them or copy & paste them from this message.

Thank you for fast answer.
I used Ctrl+F9 for insert {} . I have got an error. I think probably formula have wrong brace pairs or something... There are three '{' and only two '}'

Should I insert my data field from keyboard ( with <<>> or only field name ) or use insert filed from ribbon menu?

macropod
01-30-2013, 01:51 PM
Sorry, that should have been:
{=MOD({={MERGEFIELD MyData}-1},10000)+1}
On reflection, you can probably simplify the code to:
{=MOD({MERGEFIELD MyData},10000)}
It is impractical to try to use the ribbon/menus for this.

gregbartel
01-31-2013, 12:09 AM
Sorry, that should have been:
{=MOD({={MERGEFIELD MyData}-1},10000)+1}
On reflection, you can probably simplify the code to:
{=MOD({MERGEFIELD MyData},10000)}
It is impractical to try to use the ribbon/menus for this.

I found one problem. Some values of this field could contain combination of numbers and letters. For example 01256854AH2.
I need display on paper only 54AH2. Only last 5 chars.

Can you help ?

macropod
01-31-2013, 12:17 AM
There is no practical way of doing that via field coding. The simplest solution, if practical at your end, is to modify the Excel file by adding a column/field that reports only the right-most five characters. A suitable formula would be:
=RIGHT(A1,5)
where A1 is the cell holding the full string.