A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Merge the last 4 digits of a number that contains a hyphen



 
 
Thread Tools Display Modes
  #1  
Old June 23rd, 2005, 10:11 PM
Lani
external usenet poster
 
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  
Old June 23rd, 2005, 11:24 PM
Peter Jamieson
external usenet poster
 
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  
Old June 24th, 2005, 12:42 AM
Lani
external usenet poster
 
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?




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does the number format change in a mail merge doc? marymarsh Mailmerge 2 June 20th, 2005 07:01 PM
Number of objects thomak General Discussion 3 February 17th, 2005 11:58 AM
incorrect sums in report using 2 tables jkendrick75 Setting Up & Running Reports 22 December 13th, 2004 02:19 PM
How to run word and pass a mail merge values and fax it to the recipient Belinda Mailmerge 2 June 13th, 2004 12:49 AM
Count number of chars or digits in a cell? Parse out last char? RF Worksheet Functions 3 March 17th, 2004 08:03 PM


All times are GMT +1. The time now is 09:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.