View Single Post
  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Truncating in Mail Merge

Of course it does! I wouldn't mind but I did a web page about this

http://www.gmayor.com/formatting_word_fields.htm


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org

Laurel wrote:
{ MERGEFIELD «Cardholder_Number»\# x### } works just like the RIGHT
function in Excel and displays the last 4 digits of the cardholder
number in my letter. Simple and no math!

Thanks for your help and suggestions.
Laurel

"Laurel" wrote:

Thank you so much to you and Graham. I'm having trouble getting it
to work without syntax errors. I don't have a lot of experience with
mail merge. But while I was trying to figure it out, I came across a
numeric picture switch that drops digits to the left of the "x"
placeholder. I'm still unable to type without getting syntax errors
but theoretically would this work?

{ = 111053 + 111439 \# x## } displays "492". (example in
documentation) { = «Cardholder_Number»\# x### } (how it would maybe
work for me?)

Also, I'm still unable to key this into my document so that it
works. I can get the brackets using Ctrl-F9 but everything I type
inside gets a syntax error.

Thank you so much. You guys are great!

"Peter Jamieson" wrote:


It seems like it should be
just as simple as the RIGHT function in Excel


It does, but unfortunately it isn't.

If the account number is a whole number (or in some case, contains
a whole number) not more than around 14 or so digits long, you can
use

{ =mod({ MERGEFIELD youraccountfield },10000) } and prefix any
asterixes you need.

All the {} need to be the special field code braces that you can
insert using ctrl-F9.

If the account number is more complex there are two things you can
do other than transform your data source into another format:
a. use a DATABASE field - nasty, but see
http://tips.pjmsn.me.uk/t0004.htm b. use Word VBA to issue a SQL
query to get the data from the .csv file, and put the necessary
right() function in that query. That isn't straightforward either,
but it can usually be done as long as the .csv can be read by the
Jet ODBC driver/OLE DB provider and doesn't have more than 255
fields.

Peter Jamieson


"Laurel" wrote in message
...
Hi All,
I'd like to print just the last 4 numbers of an account number in
a mail merge letter (front fill the rest with asterisks). It seems
like it should be
just as simple as the RIGHT function in Excel but by necessity my
source document has be a CSV text document so the function has to
take place in Word. Is this possible?

Thanks so much!
Laurel