View Single Post
  #14   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Remove the leading zero from mergefield .

Hi Joergen,

Seems that in trying to keep things simple (HA!) I was a bit too aggressive
with the INT part of the formula. Instead of =INT(Data/10^5) you need
=INT(Data/100000). For some peculiar reason, 10^5 isn't being evaluated as
100000!

Here's the complete coding, including the QUOTE field wrapper I mentioned.
An advantage of using the QUOTE field wrapper is that you can have paragraph
marks separating the nested IF fields, to keep the layout just that bit more
comprehensible, without any effect on the output.

{QUOTE{SET Data {MERGEFIELD Value}}{=INT(Data/100000)}

{IF{REF Data }= "*1????" 1 {IF{REF Data }= "*2????" 2 {IF{REF Data }=
"*3????" 3 {IF{REF Data }= "*4????" 4 {IF{REF Data }= "*5????" 5 {IF{REF
Data }= "*6????" 6 {IF{REF Data }= "*7????" 7 {IF{REF Data }= "*8????" 8
{IF{REF Data }= "*9????" 9 0}}}}}}}}}

{IF{REF Data }= "*1???" 1 {IF{REF Data }= "*2???" 2 {IF{REF Data }= "*3???"
3 {IF{REF Data }= "*4???" 4 {IF{REF Data }= "*5???" 5 {IF{REF Data }=
"*6???" 6 {IF{REF Data }= "*7???" 7 {IF{REF Data }= "*8???" 8 {IF{REF
Data }= "*9???" 9 0}}}}}}}}}

{IF{REF Data }= "*1??" 1 {IF{REF Data }= "*2??" 2 {IF{REF Data }= "*3??" 3
{IF{REF Data }= "*4??" 4 {IF{REF Data }= "*5??" 5 {IF{REF Data }= "*6??" 6
{IF{REF Data }= "*7??" 7 {IF{REF Data }= "*8??" 8 {IF{REF Data }= "*9??" 9
0}}}}}}}}}

{IF{REF Data }= "*1?" 1 {IF{REF Data }= "*2?" 2 {IF{REF Data }= "*3?" 3
{IF{REF Data }= "*4?" 4 {IF{REF Data }= "*5?" 5 {IF{REF Data }= "*6?" 6
{IF{REF Data }= "*7?" 7 {IF{REF Data }= "*8?" 8 {IF{REF Data }= "*9?" 9
0}}}}}}}}}

{IF{REF Data }= "*1" 1 {IF{REF Data }= "*2" 2 {IF{REF Data }= "*3" 3 {IF{REF
Data }= "*4" 4 {IF{REF Data }= "*5" 5 {IF{REF Data }= "*6" 6 {IF{REF Data }=
"*7" 7 {IF{REF Data }= "*8" 8 {IF{REF Data }= "*9" 9 0}}}}}}}}} \*
Charformat}

Cheers

--
macropod
[MVP - Microsoft Word]


"Joergen Bondesen" wrote in message
...
Hi macropod

I have "succes" with your code and have generated at number without

leading
0.

Tomorrow I will test the barcode with my scanner.

I am trying without QUOTE... but have a copy of your advise.

But I have a slight probleme.
09810450005000600000 = 9810450005000500000 Error, because first of

the
5 last digits is 0
09810450005000060000 = 9810450005000060000 OK, because first of the

5
last digits NOT is 0
09810450005000006000 = 9810450004999906000 Error, because first of

the
5 last digits is 0

Digit no. 7 from left, will always be 5.
So instead of 5 [="*1????"] I must have 5 + 9 = 14 [="*1?????????????"]

or
do you have a better way?

15/5 = {=INT(Data/10^5)}
6/14 = {=INT(Data/10^14)} ??


I was wondering, when I have made my field-code and want to send it in a
e-mail, how do I copy the words and brackets, because a paste copy gives

me
the value?

--
Best regards
Joergen Bondesen



"macropod" wrote in message
...
Hi Joergen,

I was so intimidated by your solution.

OK, but it's really not all that complex.

Now, as for the 3of9 barcode, perhaps the simplest way to convert the
field
into one it to wrap it in a QUOTE field and use a '\* Charformat' switch
to
apply the barcode. To do this, you'd:
. select the set of fields that you've coded as per my previous post
. press Ctrl-F9 to enclose them in yet another field
. add 'QUOTE' at the beginning of the new field and '\* Charformat' at

the
end, so that you end up with
(QUOTE {SET Data {MERGEFIELD Value}}{=INT(Data/10^5)}{IF{REF Data}=
"*1????"
1
{IF{REF Data}= "*2????" 2 {IF{REF Data}= "*3????" 3 {IF{REF Data}=
"*4????"
4 {IF{REF Data}= "*5????" 5 {IF{REF Data}= "*6????" 6 {IF{REF Data}=
"*7????" 7 {IF{REF Data}= "*8????" 8 {IF{REF Data}= "*9????" 9
0}}}}}}}}}{IF{REF Data}= "*1???" 1 {IF{REF Data}= "*2???" 2 {IF{REF

Data}=
"*3???" 3 {IF{REF Data}= "*4???" 4 {IF{REF Data}= "*5???" 5 {IF{REF

Data}=
"*6???" 6 {IF{REF Data}= "*7???" 7 {IF{REF Data}= "*8???" 8 {IF{REF

Data}=
"*9???" 9 0}}}}}}}}}{IF{REF Data}= "*1??" 1 {IF{REF Data}= "*2??" 2
{IF{REF
Data}= "*3??" 3 {IF{REF Data}= "*4??" 4 {IF{REF Data}= "*5??" 5 {IF{REF
Data}= "*6??" 6 {IF{REF Data}= "*7??" 7 {IF{REF Data}= "*8??" 8 {IF{REF
Data}= "*9??" 9 0}}}}}}}}}{IF{REF Data}= "*1?" 1 {IF{REF Data}= "*2?" 2
{IF{REF Data}= "*3?" 3 {IF{REF Data}= "*4?" 4 {IF{REF Data}= "*5?" 5
{IF{REF
Data}= "*6?" 6 {IF{REF Data}= "*7?" 7 {IF{REF Data}= "*8?" 8 {IF{REF
Data}=
"*9?" 9 0}}}}}}}}}{IF{REF Data}= "*1" 1 {IF{REF Data}= "*2" 2 {IF{REF
Data}=
"*3" 3 {IF{REF Data}= "*4" 4 {IF{REF Data}= "*5" 5 {IF{REF Data}= "*6" 6
{IF{REF Data}= "*7" 7 {IF{REF Data}= "*8" 8 {IF{REF Data}= "*9" 9
0}}}}}}}}}
\* Charformat}
. apply the barcode font, at the required point size, to the 'Q' in
'QUOTE'.

Cheers

--
macropod
[MVP - Microsoft Word]


"Joergen Bondesen" wrote in message
...
Hi macropod

Sorry, my mistake. I was so intimidated by your solution. 8-)

"zz" only indicates there is more than 1 filed in the record.
Header is: "Number","Name"

--
Best regards
Joergen Bondesen


"macropod" wrote in message
...
Hi Joergen,

Is the "zz" part of the same field in your text file as the 20 digits
"09812340078901230067" (eg: "09812340078901230067zz"), or are they
separate
fields (eg: "09812340078901230067" & "zz")?

Is the "zz" part of the barcode? If so, is it always "zz", or can

other
letters be involved?

Cheers

--
macropod
[MVP - Microsoft Word]


"Joergen Bondesen" wrote in message
...
Hi Doug Robbins; Peter Jamieson; Graham Mayor and macropod

Thanks to all of you for all the answers.

I have a mailmerge field where the field from a txt-file
display 20 digits: "09812340078901230067","zz" and the next number

is
"09812340078901230068","zz" etc.

Of course I can remove the 0 (zero) from the txt-file but it is

daily,
takes
time and I can forget it.

I am using the number on a carrier (letter with a card) with a font

3of9
so
i can have a barcode.

Ouer mailermachine read the barcode and compare the number with the
number
on the card.
Cardnumber is 19 digits: 9812340078901230067 because the card is
without
0
(zero).

I hope this explains my dilemma.

I will bee back with thanks or further ask for help.


Best regards
Joergen Bondesen


"macropod" wrote in message
...
Hi Joergen,

If you *really* can't change the source file, you could code your
mailmerge
template like:
{SET Data {MERGEFIELD Value}}{=INT(Data/10^5)}{IF{REF Data}=
"*1????"

1
{IF{REF Data}= "*2????" 2 {IF{REF Data}= "*3????" 3 {IF{REF Data}=
"*4????"
4 {IF{REF Data}= "*5????" 5 {IF{REF Data}= "*6????" 6 {IF{REF

Data}=
"*7????" 7 {IF{REF Data}= "*8????" 8 {IF{REF Data}= "*9????" 9
0}}}}}}}}}{IF{REF Data}= "*1???" 1 {IF{REF Data}= "*2???" 2

{IF{REF
Data}=
"*3???" 3 {IF{REF Data}= "*4???" 4 {IF{REF Data}= "*5???" 5

{IF{REF
Data}=
"*6???" 6 {IF{REF Data}= "*7???" 7 {IF{REF Data}= "*8???" 8

{IF{REF
Data}=
"*9???" 9 0}}}}}}}}}{IF{REF Data}= "*1??" 1 {IF{REF Data}= "*2??"

2
{IF{REF
Data}= "*3??" 3 {IF{REF Data}= "*4??" 4 {IF{REF Data}= "*5??" 5

{IF{REF
Data}= "*6??" 6 {IF{REF Data}= "*7??" 7 {IF{REF Data}= "*8??" 8

{IF{REF
Data}= "*9??" 9 0}}}}}}}}}{IF{REF Data}= "*1?" 1 {IF{REF Data}=
"*2?"

2
{IF{REF Data}= "*3?" 3 {IF{REF Data}= "*4?" 4 {IF{REF Data}= "*5?"

5
{IF{REF
Data}= "*6?" 6 {IF{REF Data}= "*7?" 7 {IF{REF Data}= "*8?" 8

{IF{REF
Data}=
"*9?" 9 0}}}}}}}}}{IF{REF Data}= "*1" 1 {IF{REF Data}= "*2" 2
{IF{REF
Data}=
"*3" 3 {IF{REF Data}= "*4" 4 {IF{REF Data}= "*5" 5 {IF{REF Data}=

"*6"
6
{IF{REF Data}= "*7" 7 {IF{REF Data}= "*8" 8 {IF{REF Data}= "*9" 9
0}}}}}}}}}

Looks rather intimidating, doesn't it!

Here's the same coding broken down into its component parts, and

an
explanation of how things work:

{SET Data {MERGEFIELD Value}}
This simply uses a SET field to create a bookmarked copy of your
mailmerge
value. Substitute the real name for 'Value'.

{=INT(Data/10^5)}
This reduces the field length to the 15-digit maximum that Word

can
handle,
stripping off any leading 0s, and displays whatever's left.

{IF{REF Data}= "*1????" 1 {IF{REF Data}= "*2????" 2 {IF{REF Data}=
"*3????"
3 {IF{REF Data}= "*4????" 4 {IF{REF Data}= "*5????" 5 {IF{REF

Data}=
"*6????" 6 {IF{REF Data}= "*7????" 7 {IF{REF Data}= "*8????" 8

{IF{REF
Data}= "*9????" 9 0}}}}}}}}}
This set of 9 nested IF fields tests the 5th-last digit in the

field
and
displays whatever number it is.

{IF{REF Data}= "*1???" 1 {IF{REF Data}= "*2???" 2 {IF{REF Data}=
"*3???"
3
{IF{REF Data}= "*4???" 4 {IF{REF Data}= "*5???" 5 {IF{REF Data}=
"*6???"
6
{IF{REF Data}= "*7???" 7 {IF{REF Data}= "*8???" 8 {IF{REF Data}=
"*9???"
9
0}}}}}}}}}
This set of 9 nested IF fields tests the 4th-last digit in the

field
and
displays whatever number it is.

{IF{REF Data}= "*1??" 1 {IF{REF Data}= "*2??" 2 {IF{REF Data}=
"*3??"

3
{IF{REF Data}= "*4??" 4 {IF{REF Data}= "*5??" 5 {IF{REF Data}=
"*6??"

6
{IF{REF Data}= "*7??" 7 {IF{REF Data}= "*8??" 8 {IF{REF Data}=
"*9??"

9
0}}}}}}}}}
This set of 9 nested IF fields tests the 3rd-last digit in the

field
and
displays whatever number it is.

{IF{REF Data}= "*1?" 1 {IF{REF Data}= "*2?" 2 {IF{REF Data}= "*3?"

3
{IF{REF
Data}= "*4?" 4 {IF{REF Data}= "*5?" 5 {IF{REF Data}= "*6?" 6

{IF{REF
Data}=
"*7?" 7 {IF{REF Data}= "*8?" 8 {IF{REF Data}= "*9?" 9 0}}}}}}}}}
This set of 9 nested IF fields tests the 2nd-last digit in the

field
and
displays whatever number it is.

{IF{REF Data}= "*1" 1 {IF{REF Data}= "*2" 2 {IF{REF Data}= "*3" 3
{IF{REF
Data}= "*4" 4 {IF{REF Data}= "*5" 5 {IF{REF Data}= "*6" 6 {IF{REF
Data}=
"*7" 7 {IF{REF Data}= "*8" 8 {IF{REF Data}= "*9" 9 0}}}}}}}}}
This set of 9 nested IF fields tests the last digit in the field

and
displays whatever number it is.

Each set of 9 nested IF fields is basically a compilation 9 sets

of:
{IF{REF Data}= "*#?" # !},
where the:
. field braces (i.e. '{ }') are created in paird via Ctrl-F9;
. '*' is a wildcard representing all numbers in the field

preceding
the
number you're looking for;
. '#' is the number you're looking for;
. '?' is a wildcard representing each succeeding number in the
field;
and
. '!' represents the next number or nested IF test.

If you want to group the whole lot together (eg for easier
re-positioning
as
a group), you could embed them inside a QUOTE field.

Cheers

--
macropod
[MVP - Microsoft Word]


"Joergen Bondesen" wrote in message
...
Hi NG.

I have a mailmerge field where the field from a txt-file display

20
digits:
'09812340078901230067'
I want only displayed 19 digits '9812340078901230067' because

zero
may
not
be displayed.
It is not posssible to remove the leading zero in the txt-file.

-----
Best Regards from
Joergen Bondesen