Reply
 
Thread Tools Display Modes
  #1   Report Post  
Lani
 
Posts: n/a
Default Merge the last 4 digits of a number that contains a hyphen

I use Microsoft Word 2002 (XP). I am trying to merge the last 4 digits of a
number that in some cases includes a hyphen. The following switch works if
the number does not contain a hyphen i.e. Number = 123456789:
{QUOTE "XXXX"{MERGEFIELD Number \# x####}} field result = XXXX6789
When the number contains a hyphen Word subtracts the last number from the
four numbers that precede the hyphen i.e. 12345678-9 the field result =
XXXX5669. How can I make Word ignore the hyphen and merge the field result =
XXXX678-9?
  #2   Report Post  
Peter Jamieson
 
Posts: n/a
Default

Unfortunately I don't think you can do it using a field. Yes, there is a
strange "feature" where Word calculates some simple strings that look like
numeric expressions if you apply a numeric format, but when you think about
it, 12345678-9 isn't a number - it's an expression. So you really need a
character format that extracts the last 4 digits and anything along with it
(and there aren't any such character formats switches).

So you either have to fix the problem in the data source, or you have to do
something like use VBA and Mailmerge events to extract the correct text and
avoid applying formats. I'd head for the first of those if possible.

Peter Jamieson

"Lani" wrote in message
...
I use Microsoft Word 2002 (XP). I am trying to merge the last 4 digits of
a
number that in some cases includes a hyphen. The following switch works if
the number does not contain a hyphen i.e. Number = 123456789:
{QUOTE "XXXX"{MERGEFIELD Number \# x####}} field result = XXXX6789
When the number contains a hyphen Word subtracts the last number from the
four numbers that precede the hyphen i.e. 12345678-9 the field result =
XXXX5669. How can I make Word ignore the hyphen and merge the field
result =
XXXX678-9?



  #3   Report Post  
Lani
 
Posts: n/a
Default

I will try to use VBA to extract the correct text. Thank you for the input.

"Peter Jamieson" wrote:

Unfortunately I don't think you can do it using a field. Yes, there is a
strange "feature" where Word calculates some simple strings that look like
numeric expressions if you apply a numeric format, but when you think about
it, 12345678-9 isn't a number - it's an expression. So you really need a
character format that extracts the last 4 digits and anything along with it
(and there aren't any such character formats switches).

So you either have to fix the problem in the data source, or you have to do
something like use VBA and Mailmerge events to extract the correct text and
avoid applying formats. I'd head for the first of those if possible.

Peter Jamieson

"Lani" wrote in message
...
I use Microsoft Word 2002 (XP). I am trying to merge the last 4 digits of
a
number that in some cases includes a hyphen. The following switch works if
the number does not contain a hyphen i.e. Number = 123456789:
{QUOTE "XXXX"{MERGEFIELD Number \# x####}} field result = XXXX6789
When the number contains a hyphen Word subtracts the last number from the
four numbers that precede the hyphen i.e. 12345678-9 the field result =
XXXX5669. How can I make Word ignore the hyphen and merge the field
result =
XXXX678-9?




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extra digits in merge from Excel (Office 2003) Ann Scharpf Mailmerge 3 June 15th 05 11:14 AM
Printing select number of labels from a mail merge result Judy Mailmerge 1 May 31st 05 08:50 PM
Number of pages incorrect while doing mail merge Eadie Mailmerge 0 January 21st 05 03:53 PM
maximum number of columns in Word for Mail Merge EllenF Mailmerge 3 January 19th 05 11:44 PM
merge document with columns and page number in header resets Island Grrl Mailmerge 1 January 12th 05 03:40 AM


All times are GMT +1. The time now is 06:32 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"