Mail Merge two fields that have multiple lines with new line control code

E

Eric Li

Hi,

I am using MailMerge.OpenDataSource to merge many fields. There are two
fields are multiple lines with new line control code in it ("\n"). I can
merge only one field (has multiple lines) without any problem but when
merging two fields (both have multiple lines), I got the following error:

"Data fields must be separated from each other by a character called a field
delimiter. Similarly, data records must be separated by a record delimiter.
Use the lists below to select the appropriate delimiter."

I am using "^" as my delimiter and can't find any wrong with my delimiter.
As long as I only use one field that has multiple lines, it will be OK, even
I have other fields that have only one line value.

Any idea?

Thanks in advance.

Eric
 
C

Cindy M -WordMVP-

Hi Eric,

Which version of Word is this?

I assume the data source is a text file. And are you using a "new line"
generated by pressing the Enter key (Chr(13) or some combination with that
character) as the record delimiter? Or something else (you don't specify which
kind of delimiter the ^ is...)?

Have you placed each field's content in "quotes"?
I am using MailMerge.OpenDataSource to merge many fields. There are two
fields are multiple lines with new line control code in it ("\n"). I can
merge only one field (has multiple lines) without any problem but when
merging two fields (both have multiple lines), I got the following error:

"Data fields must be separated from each other by a character called a field
delimiter. Similarly, data records must be separated by a record delimiter.
Use the lists below to select the appropriate delimiter."

I am using "^" as my delimiter and can't find any wrong with my delimiter.
As long as I only use one field that has multiple lines, it will be OK, even
I have other fields that have only one line value.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
E

Eric Li

Hi, Cindy,

Thank you for reply.

I am using C# to generate my contents for each field.

For example, I have the following values for one field:

"this is first line\n" + "this is second line\n" + "this is last line"

and I am using "^" as my delimiter for each field pair.

Yes, I have tried add "quotes" to my content but still didn't work.

Thanks for spending your time for me. :)

Eric
 
E

Eric Li

Hi, Cindy,

I finally found out what's going on. It's my mistake.

When I created the text file, I enter a carriage return on the last line.
That's the problem. Once I remove the carriage return. Everything is working
fine. Thanks for your help.


Eric
 
C

Cindy M -WordMVP-

Hi Eric,
I finally found out what's going on. It's my mistake.

When I created the text file, I enter a carriage return on the last line.
That's the problem. Once I remove the carriage return. Everything is working
fine.
Glad you tracked it down :)

Cindy Meister
 
E

Eric Li

Hi, Cindy,

Now I have another issue. The mailmerge function that I used in Word 2000 is
OK but it doesn't work on Word 2002. The text file that I used is identical
in Word 2000 and 2002. Is there any difference between 2000 and 2002 when
you create text file for mailmerge?

The error I got is "This merge field is used in the main document, but it
does not exist in the data source".

Here is my text file example:

field 1^field 2^field 3
"data 1"^"data 2"^"data 3"

I am using "^" as my field delimiter and carriage return as my record
delimiter.

Do you have any idea? Thanks.



Eric
 
C

Cindy M -WordMVP-

Hi Eric,

the most obvious difference between Word 2000 and 2002 is that the latter uses
OLE DB by default to connect to the data, while Word 2000 will use either
Word's internal text converter or possibly ODBC.

If you change the file extension of the text file to something really
abstruse, such as *.prn, then test in both versions, what kinds of results do
you get?
Now I have another issue. The mailmerge function that I used in Word 2000 is
OK but it doesn't work on Word 2002. The text file that I used is identical
in Word 2000 and 2002. Is there any difference between 2000 and 2002 when
you create text file for mailmerge?

The error I got is "This merge field is used in the main document, but it
does not exist in the data source".

Here is my text file example:

field 1^field 2^field 3
"data 1"^"data 2"^"data 3"

I am using "^" as my field delimiter and carriage return as my record
delimiter.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
E

Eric Li

Hi, Cindy,

You are right. It's the internal text converter issue.

If I use "\r" (carriage return) only as my record delimiter in Word 2000, it
is OK but it is not OK in Word 2002. I have to use "\r\n" (carriage return +
new line) as record delimiter in Word 2002.

The file extension that I use for my text file is "DOC". Therefore, Word
2002 is using DOC converter to interpreter "\r". I will try to use different
extension.

By the way, is there any length limitation for field ID? I am using a very
long field ID but Word 2002 will truncated my field ID and mailmerge can't
recognize the field any more.


Thanks.


Eric
 
C

Cindy M -WordMVP-

Hi Eric,
You are right. It's the internal text converter issue.

If I use "\r" (carriage return) only as my record delimiter in Word 2000, it
is OK but it is not OK in Word 2002. I have to use "\r\n" (carriage return +
new line) as record delimiter in Word 2002.

The file extension that I use for my text file is "DOC". Therefore, Word
2002 is using DOC converter to interpreter "\r". I will try to use different
extension.
Hmmm. I'll be interested in the result. I'm not sure whether OLE DB will kick
in if a data source is named *.doc, or not. You might also give ODBC a try, as
this is likely to give the most "even" results across versions. Although you
might have to set up a DSN to specifically recognize the ^ field delimiter.
By the way, is there any length limitation for field ID? I am using a very
long field ID but Word 2002 will truncated my field ID and mailmerge can't
recognize the field any more.
Word 2002 came up with a new thing that cuts off field names at 40 characters.
How is the problem manifesting itself in your case? I've reported the problem
back to Microsoft before, but we didn't get very far because we couldn't pin
down a 100% reproducible case.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
E

Eric Li

Hi, Cindy,

After couple of testing, I found out that using "\r\n" as record delimiter
is OK in Word 2000, 2002 and 2003. The reason that I had this problem in
different platforms earlier is because I converted "\r\n" to "\r" in my
field data (I thought "\r\n" will be treated as record delimiter.). after
keeping "\r\n" in field data and using "quotes" (thanks for your tips),
everything is fine now.

Regarding to field name issue, Word 2002 will truncated field name that
exceeds 40 characters (if field is inserted by program, not by typing).
Actually field name will be truncated by Word 2000 and 2003 too but
internally Word 2000 and 2003 still can recogize field name. Word 2002 can't
recognize field name once name has been truncated. Therefore nothing we can
do about it except for using shorter name.

Thanks for your tips. You are an excellent helper. :)



Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top