Masking Social Security # in a Word merge doc

J

jared.hildebrandt

Hi all,
I am trying to mask a SSN to look literally like this XXX-XX-1234 or
some other combination where most of the numbers are X'ed out. I
couldn't find any easy way to do this in Word, I am alos kinda new to
the merge docs. Any help would be great!
 
P

Peter Jamieson

The best and safest way to do this is to modify the data source in some way
so that instead of (or as well as) receiving a field with (e.g.) 123-45-6789
in it, you also receive 6789 and prepend that with XXX-XX- use that directly
where the SSN needs to be partially hidden.

How to do that depends on the data source (what is it?), but for example if
the SSN is stored as a string in Access, all you really need do is create a
query that creates a new column using something like right(ssnfield,4) and
use that as the data source for the merge. Prcisely how to do that depends
on how consistent the SSN format is - if it is invariably xxx-xx-xxxx then
it's straightforward.

Peter Jamieson

[
Most other methods require that you obscure the SSN in some way, and the
trouble with that is that it may look obscured in print and on screen, but
if you merge to new documents or to e-mail, the full SSN may be sitting
there as plain as day.

However, because the digits in fonts all have the same width (well, usually,
anyway) you might be able to use use something like

{ MERGEFIELD ssnfield }{ ADVANCE \l 70 } { ADVANCE \l 40 }XXX-XX-{
ADVANCE \r 30 }

where
a. all the {} are the special field braces you can insert using ctrl-F9
b. the characters between \l 70 } and { ADVANCE are block characters, e.g.
the Unicode FULL BLOCK character no. 0x2588 (hex 2588) that you can insert
using Insert|Symbol - select them and use Format|Font to apply White colour.
These are used to blank out the digits before "-5678" completely before
inserting the "XXX-XX-" mask.
c. you will need to adjust the font and size of the block characters, the
XXX-XX- "mask", and the numbers in the ADVANCE fields

You might also be able to do something using a nested EQ field, e.g.

{ EQ \o\al\({ MERGEFIELD ssnfield }, ,XXX-XX-)}

where the spaces between , , are also block characters coloured white, as
above, and you would need to adjust the sizes of everything to make it work.

But personally, I would avoid all methods that do anything like that for the
reason I've stated.
]
 
J

J-Rod

Thanks Peter. I believe that my data is coming from a stored
procedure, so i may be able to modify the query as you suggested. The
spec changed a little from what i had originally and being that i am
new in word merge, what ways could i use to format it 123-45-xxxx? If
you could give me an alternative or two that would be great. I will
try to modify your examples that you already gave me and see if i can
figure it out as well.
 
P

Peter Jamieson

new in word merge, what ways could i use to format it 123-45-xxxx? If

1. "Change the query" approach: use e.g. left(ssnfield,6). Actually I think
if you are using SQl Server you need something more like
substring(ssnfield(1,6) or some such.

2. "Use ADVANCE fields" approach. start with something more like the
following and adjust

{ MERGEFIELD ssnfield }{ ADVANCE \l 50 } { ADVANCE \l 50 }-xxxx

3. "Use EQ field" approach. Try something more like

{ EQ \o\ar({ MERGEFIELD ssnfield }, ,-XXXX)}

(NB I think I put an extra \ in the earlier example after al where there
should not be one)

4. You can also consider putting the field in a table cell or frame with a
fixed width and height, so that the right 4 digits are truncated. Then (if
you can) put the -XXXX immediately afterwards. (Frames are the predecessors
of "Text boxes" in Word and are typically more reliable when you're using
merge fields. You can create them by opening Tools|Customize|Commands,
select category All Commands, locate the InsertFrame command and drag it to
a toolbar, then use that. Or create a textbox, select it, right-click,
Format Text box, Text box tab, Convert to frame.

Again, personally I think (1) is the simplest and safest approach. However,
you do not necessarily have to have special access to your database to do it
because you can use a Word VBA OpenDataSource method to issue SQL, e.g. if
your data is coming from a view called myview, the SQL might be something
like

SELECT [m].*, substring([m].[ssnfield],1,6) AS `partialssn` FROM [myview]
[m]

Peter Jamieson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top