# Thread: Word Merge 2013 - Masking Output of merge fields - show only the LAST 4 digits of numbers

1. ## Word Merge 2013 - Masking Output of merge fields - show only the LAST 4 digits of numbers

Hi,

I know there has been much written about masking all but the last 4 digits of a Social Security Number, but since most banks make you use the last four digits of your Social Security Number as a validation check... how can I mask all BUT the last 4 digits?

Also, I need to mask the last 4 digits of an account number that comes through as a merge field, and they are in random lengths... somethimes with dashes, sometimes without.

Paul (Macropod) I know you gave the following example:

{QUOTE
{SET ID {MERGEFIELD SSN}}
{SET EXP1{=-{=-{ID}-ID}/2}}
{SET EXP2{=-({ID}*(-1)-{ID})/2}}
{SET EXP3{=-({EXP1}+{EXP2}-{ID})}}"XXX-XX-"{EXP3 # 0000}}

and my attempt at tweaking it, was a failure:

{QUOTE
{SET ID {MERGEFIELD SSN}}
{SET EXP1{=-{=-{ID}-ID}/2}}
{SET EXP2{=-({ID}*(-1)-{ID})/2}}
{SET EXP3{=-({EXP1}+{EXP2}-{ID})}}{EXP3 # 0000}"XXXX-"}

Please lend a girl a hand before I go nuts... :-)

Annie

2. The field code I gave already masks all except the last four digits of a SSN, so that seems to answer your first question.

As for account #s, you can use a similar approach, with a field coded as:
{QUOTE
{SET Acc {MERGEFIELD Account}}
{SET Acc1{=-{=-{Acc}-Acc}/2}}
{SET Acc2{=-({Acc}*(-1)-{Acc})/2}}
{SET Acc3{=-({Acc1}+{Acc2}-{Acc})}}"###-"{=MOD({Acc3},10000) \# 0000}}
Apart from the changes in the bookmark names (to guard against Word getting confused as to which references it's supposed to use at a given point), the only substantive difference is the field code for last line, which has uses a MOD equation to ensure only four digits are output and has just three # characters for the mask (since it's impossible to vary the number of such characters according to the A/c# length. Of course, if the A/c # has letters in it, you won't get a valid output. If that's what you're dealing with, you'll need to modify the data source to add a field that contains just the last four characters of the A/c #.

3. Hi Paul,

I can't get the code to work - is there any way you can help me? I will pay for your time.
I am at my wits end trying to figure out how to mask a number correctly, and it just won't work no matter what I try!

Annie

4. See attached. Mergefields named SSN and Account, respectively, are assumed.

5. Hi Paul,

OK, what if the account number values range from 5 characters to 16? I still would only like the last 3 digits to show up, since some of the account numbers are so little...

Are you sure there is no way I can hire you for a couple of hours, to help me work through this?

I have another case where I need to subtract 1 business day from a given date. I have no control over what the date is, it could be 03/01/2015 or 12/15/2015...

You have been extremely helpful and I would stop bugging you if I could figure this out... :-)
Annie

6. Originally Posted by AnnieBTX
Hi Paul,

OK, what if the account number values range from 5 characters to 16? I still would only like the last 3 digits to show up, since some of the account numbers are so little...
so change:
{=MOD({Acc3 # 0000},10000)}
to:
{=MOD({Acc3 # 0000},1000)}
Are you sure there is no way I can hire you for a couple of hours, to help me work through this?
No - what I do is gratis.
I have another case where I need to subtract 1 business day from a given date. I have no control over what the date is, it could be 03/01/2015 or 12/15/2015...
To see how to do this and just about everything else you might want to do with dates in Word, check out my Microsoft Word Date Calculation Tutorial. It's a 'Sticky' at the top of this forum:
http://windowssecrets.com/forums/sho...ation-Tutorial
In particular, look at the items titled 'Handling Weekends and Holidays in Calculated Dates' and 'Date and Time Calculations In A Mailmerge'. Do read the document's introductory material. Configuring a Word mailmerge to handle a simple '+/- x days' calculation is not too difficult. Configuring a Word mailmerge to handle business-day calculations, however, is quite an involved process that requires a precise understanding of how public holidays are determined. You may find it easier to modify the data source.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•