Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Andy Andy is offline
external usenet poster
 
Posts: 90
Default Only displaying part of a merged field/formatting parts of a merge

eld differently...

The software i use is web-based and all the information stored against a
customer has a reference that can be used to pre-populate information on any
documents generated via the application.

I have several document templates that have reference codes (they work the
same as merge field codes) and, when the document is generated, pick up the
information stored in those fields for the particular customer i am dealing
with.

In some instances, for example credit card number, I only wish to display
part of the merged field in my document without having to alter the stored
data.

i.e. Number stored 1234 1234 1234 1234
currently populated 1234 1234 1234 1234
would prefer 1234 **** **** 1234

I am using Word 2003 SP2.


  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Only displaying part of a merged field/formatting parts of a merge

1. It's difficult to make suggestions about how to proceed without know a
bit more about how Word is getting its data and what programming options you
have. e.g.
a. which version of Word can you rely on?
b. can you use VBA macros?
c. can you modify the data source as Word sees it? (what type of data
source does Word think it is dealing with

I have several document templates that have reference codes (they work the
same as merge field codes)


d. only Merge Fields really work the same as Merge Fields. With almost any
other approach, some application must be stuffing the data into the merge
fields and that would typically be an opportunity to alter what is inserted.

For a numeric value, you may be able to do what you want using fields and
formatting switches - in this case you could start with

{ =int({ MERGEFIELD myfield },1000000000000) \#"0000 **** **** " }{ =mod({
MERGEFIELD myfield },10000) \#0000 }

where each pair of {} are the special field brace characters you can insert
using ctrl-F9. However, there can be problems working with numbers with this
many digits and you should test that the mod() function in particular works
with any value you throw at it.
--
Peter Jamieson
http://tips.pjmsn.me.uk

"Andy" wrote in message
...
eld differently...

The software i use is web-based and all the information stored against a
customer has a reference that can be used to pre-populate information on
any
documents generated via the application.

I have several document templates that have reference codes (they work the
same as merge field codes) and, when the document is generated, pick up
the
information stored in those fields for the particular customer i am
dealing
with.

In some instances, for example credit card number, I only wish to display
part of the merged field in my document without having to alter the stored
data.

i.e. Number stored 1234 1234 1234 1234
currently populated 1234 1234 1234 1234
would prefer 1234 **** **** 1234

I am using Word 2003 SP2.



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Andy Andy is offline
external usenet poster
 
Posts: 90
Default Only displaying part of a merged field/formatting parts of a m

Thanks Peter,
a) I am using Word 2003 SP2. 11.8106.8107.
b) I can use VBA Macros, although the documents generated are in RTF format
so the macros will have to be written in normal.doc, and i would then have to
update normal.doc on all machines. Another method would be preferable.
c) The data is being drawn from a .net application. I would prefer not to
edit the source data as it already applies to several thousand records.
There is no easy way to alter the source data, or the format of the source
data.
d) I appreciate they are not strictly merge fields but, essentially, they do
the same thing for me - i'm not really sure of the ins and outs of this i'm
afraid.

Basically if field 200123 contains the number 1234123412341234 and my word
document contains [!matter:200123], then the word document will populate
1234123412341234 when generated.

The [!matter...] codes work the same way if placed inside { } braces, i do
use them in conjunction with switches and field codes elsewhere for other
tasks.

I think that the only way to acheive what i need is to change the data AFTER
it has been merged to the document. The field codes mod() etc did not work
for me, they returned a *Syntax error....

Although i would prefer to avoid VBA for reasons above, is there a way of
using VBA to select strings of a merged field (i.e. select char 1,2,3,4)
which i could then allocate a bookmark to?

Once again, thanks for your time.

Andy.
"Peter Jamieson" wrote:

1. It's difficult to make suggestions about how to proceed without know a
bit more about how Word is getting its data and what programming options you
have. e.g.
a. which version of Word can you rely on?
b. can you use VBA macros?
c. can you modify the data source as Word sees it? (what type of data
source does Word think it is dealing with

I have several document templates that have reference codes (they work the
same as merge field codes)


d. only Merge Fields really work the same as Merge Fields. With almost any
other approach, some application must be stuffing the data into the merge
fields and that would typically be an opportunity to alter what is inserted.

For a numeric value, you may be able to do what you want using fields and
formatting switches - in this case you could start with

{ =int({ MERGEFIELD myfield },1000000000000) \#"0000 **** **** " }{ =mod({
MERGEFIELD myfield },10000) \#0000 }

where each pair of {} are the special field brace characters you can insert
using ctrl-F9. However, there can be problems working with numbers with this
many digits and you should test that the mod() function in particular works
with any value you throw at it.
--
Peter Jamieson
http://tips.pjmsn.me.uk

"Andy" wrote in message
...
eld differently...

The software i use is web-based and all the information stored against a
customer has a reference that can be used to pre-populate information on
any
documents generated via the application.

I have several document templates that have reference codes (they work the
same as merge field codes) and, when the document is generated, pick up
the
information stored in those fields for the particular customer i am
dealing
with.

In some instances, for example credit card number, I only wish to display
part of the merged field in my document without having to alter the stored
data.

i.e. Number stored 1234 1234 1234 1234
currently populated 1234 1234 1234 1234
would prefer 1234 **** **** 1234

I am using Word 2003 SP2.




  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Only displaying part of a merged field/formatting parts of a m

d) I appreciate they are not strictly merge fields but, essentially, they
do
the same thing for me - i'm not really sure of the ins and outs of this
i'm
afraid.


It sounds as if you are using a third party application that has its own
approach to merging data. But the question then is: does it actually modify
the RTF before the RTF is even opened in Word? Or what?

The field codes mod() etc did not work
for me, they returned a *Syntax error....


Did you use ctrl-F9 to insert each pair of {} braces? Unfortuantely, if
there is a third party program preprocessing Word content in some way it's a
bit difficult to tell what it's going to do and when!

I think that the only way to acheive what i need is to change the data
AFTER
it has been merged to the document.


You then face the difficulty of having to have code in a template (which you
mentioned) or having some other way to insert the correct result (cf.
http://tips.pjmsn.me.uk/t0004.htm , but to do that you have to have a .dsn
or .udl file on every target system.

The only other approach IMO: process the .rtf yourself using code, stuffing
in the values you want from the database, before the .rtf even reaches Word.
I guess you would only have to do that for the fields that your existing
approach cannot cope with.

--
Peter Jamieson
http://tips.pjmsn.me.uk

"Andy" wrote in message
...
Thanks Peter,
a) I am using Word 2003 SP2. 11.8106.8107.
b) I can use VBA Macros, although the documents generated are in RTF
format
so the macros will have to be written in normal.doc, and i would then have
to
update normal.doc on all machines. Another method would be preferable.
c) The data is being drawn from a .net application. I would prefer not to
edit the source data as it already applies to several thousand records.
There is no easy way to alter the source data, or the format of the source
data.
d) I appreciate they are not strictly merge fields but, essentially, they
do
the same thing for me - i'm not really sure of the ins and outs of this
i'm
afraid.

Basically if field 200123 contains the number 1234123412341234 and my word
document contains [!matter:200123], then the word document will populate
1234123412341234 when generated.

The [!matter...] codes work the same way if placed inside { } braces, i do
use them in conjunction with switches and field codes elsewhere for other
tasks.

I think that the only way to acheive what i need is to change the data
AFTER
it has been merged to the document. The field codes mod() etc did not
work
for me, they returned a *Syntax error....

Although i would prefer to avoid VBA for reasons above, is there a way of
using VBA to select strings of a merged field (i.e. select char 1,2,3,4)
which i could then allocate a bookmark to?

Once again, thanks for your time.

Andy.
"Peter Jamieson" wrote:

1. It's difficult to make suggestions about how to proceed without know a
bit more about how Word is getting its data and what programming options
you
have. e.g.
a. which version of Word can you rely on?
b. can you use VBA macros?
c. can you modify the data source as Word sees it? (what type of data
source does Word think it is dealing with

I have several document templates that have reference codes (they work
the
same as merge field codes)


d. only Merge Fields really work the same as Merge Fields. With almost
any
other approach, some application must be stuffing the data into the merge
fields and that would typically be an opportunity to alter what is
inserted.

For a numeric value, you may be able to do what you want using fields and
formatting switches - in this case you could start with

{ =int({ MERGEFIELD myfield },1000000000000) \#"0000 **** **** " }{
=mod({
MERGEFIELD myfield },10000) \#0000 }

where each pair of {} are the special field brace characters you can
insert
using ctrl-F9. However, there can be problems working with numbers with
this
many digits and you should test that the mod() function in particular
works
with any value you throw at it.
--
Peter Jamieson
http://tips.pjmsn.me.uk

"Andy" wrote in message
...
eld differently...

The software i use is web-based and all the information stored against
a
customer has a reference that can be used to pre-populate information
on
any
documents generated via the application.

I have several document templates that have reference codes (they work
the
same as merge field codes) and, when the document is generated, pick up
the
information stored in those fields for the particular customer i am
dealing
with.

In some instances, for example credit card number, I only wish to
display
part of the merged field in my document without having to alter the
stored
data.

i.e. Number stored 1234 1234 1234 1234
currently populated 1234 1234 1234 1234
would prefer 1234 **** **** 1234

I am using Word 2003 SP2.





  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Only displaying part of a merged field/formatting parts of a m

Hi Andy,

You can suppress the digits in the middle of the string, but the field coding to do so is a bit complicated. That's because Word
can't do maths with more than 15 digits, so a workaround is needed. Here's the code:

{QUOTE{SET Data {MERGEFIELD Value}}{=INT(Data/10000000000000000)}"-****-****-"

{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}}}}}}}}}}

The above field coding includes 4 sets of nested IF fields. Each set of nested IF fields is 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.
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.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Andy" wrote in message ...
Thanks Peter,
a) I am using Word 2003 SP2. 11.8106.8107.
b) I can use VBA Macros, although the documents generated are in RTF format
so the macros will have to be written in normal.doc, and i would then have to
update normal.doc on all machines. Another method would be preferable.
c) The data is being drawn from a .net application. I would prefer not to
edit the source data as it already applies to several thousand records.
There is no easy way to alter the source data, or the format of the source
data.
d) I appreciate they are not strictly merge fields but, essentially, they do
the same thing for me - i'm not really sure of the ins and outs of this i'm
afraid.

Basically if field 200123 contains the number 1234123412341234 and my word
document contains [!matter:200123], then the word document will populate
1234123412341234 when generated.

The [!matter...] codes work the same way if placed inside { } braces, i do
use them in conjunction with switches and field codes elsewhere for other
tasks.

I think that the only way to acheive what i need is to change the data AFTER
it has been merged to the document. The field codes mod() etc did not work
for me, they returned a *Syntax error....

Although i would prefer to avoid VBA for reasons above, is there a way of
using VBA to select strings of a merged field (i.e. select char 1,2,3,4)
which i could then allocate a bookmark to?

Once again, thanks for your time.

Andy.
"Peter Jamieson" wrote:

1. It's difficult to make suggestions about how to proceed without know a
bit more about how Word is getting its data and what programming options you
have. e.g.
a. which version of Word can you rely on?
b. can you use VBA macros?
c. can you modify the data source as Word sees it? (what type of data
source does Word think it is dealing with

I have several document templates that have reference codes (they work the
same as merge field codes)


d. only Merge Fields really work the same as Merge Fields. With almost any
other approach, some application must be stuffing the data into the merge
fields and that would typically be an opportunity to alter what is inserted.

For a numeric value, you may be able to do what you want using fields and
formatting switches - in this case you could start with

{ =int({ MERGEFIELD myfield },1000000000000) \#"0000 **** **** " }{ =mod({
MERGEFIELD myfield },10000) \#0000 }

where each pair of {} are the special field brace characters you can insert
using ctrl-F9. However, there can be problems working with numbers with this
many digits and you should test that the mod() function in particular works
with any value you throw at it.
--
Peter Jamieson
http://tips.pjmsn.me.uk

"Andy" wrote in message
...
eld differently...

The software i use is web-based and all the information stored against a
customer has a reference that can be used to pre-populate information on
any
documents generated via the application.

I have several document templates that have reference codes (they work the
same as merge field codes) and, when the document is generated, pick up
the
information stored in those fields for the particular customer i am
dealing
with.

In some instances, for example credit card number, I only wish to display
part of the merged field in my document without having to alter the stored
data.

i.e. Number stored 1234 1234 1234 1234
currently populated 1234 1234 1234 1234
would prefer 1234 **** **** 1234

I am using Word 2003 SP2.





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
Formatting Merged field in mail merge Peterg Microsoft Word Help 3 January 8th 08 11:56 PM
How to create an email from mail merge including a hyperlink, so that the value of a merged field is included as part of the hyperlink URL, not just part of its text. [email protected] Mailmerge 4 August 22nd 07 06:18 PM
How to create an email from mail merge including a hyperlink, so that the value of a merged field is included as part of the hyperlink URL, not just part of its text. [email protected] Mailmerge 0 August 17th 07 03:52 PM
Formatting specific parts of field results jezzica85 Microsoft Word Help 2 September 5th 06 07:49 AM
Mail merge field isn't displaying all the text in a field. Can I . mojohubbard Mailmerge 3 March 28th 05 04:45 PM


All times are GMT +1. The time now is 09:40 AM.

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"