MailMerge field problem

V

Vasile

Hello !

I'm trying to read the mailmerge fields values using the
following VBA code:

If ActiveDocument.MailMerge.MainDocumentType =
wdFormLetters Then
Dim strtmp As String
For Each f In
ActiveDocument.MailMerge.DataSource.FieldNames
strtmp = CStr
(ActiveDocument.MailMerge.DataSource.DataFields
(f.Name).Value)

'...
Next
End If


The problem is that if the lenght of merge field's value
is greater than 255 chars then
ActiveDocument.MailMerge.DataSource.DataFields
(f.Name).Value returns only the first 255 characters.

Is this a known bug or is there any workaround for this?

Many thanks,
Vasile
 
C

Cindy M -WordMVP-

Hi Vasile,

I wasn't aware of the behavior, but it doesn't surprise me.
Officially, the amount of data that comes across the
mailmerge link is limited to 255 characters. For ever,
there was a "trick" to getting more than this information
for memo fields; the loophole was plugged temporarily in
Word 2000, then opened back up (to a limit of 65,000+, if I
remember correctly) in SP1. And this is the state through
Word 2003, I believe.

So it's not surprising that the VBA functionality works
with this 255 character limit. I'd say, if you really want
this information, set up an ADO or DAO connection to the
data source, using the same SELECT as for the mail merge,
and get the information that way.
I'm trying to read the mailmerge fields values using the
following VBA code:

If ActiveDocument.MailMerge.MainDocumentType =
wdFormLetters Then
Dim strtmp As String
For Each f In
ActiveDocument.MailMerge.DataSource.FieldNames
strtmp = CStr
(ActiveDocument.MailMerge.DataSource.DataFields
(f.Name).Value)

'...
Next
End If


The problem is that if the lenght of merge field's value
is greater than 255 chars then
ActiveDocument.MailMerge.DataSource.DataFields
(f.Name).Value returns only the first 255 characters.

Is this a known bug or is there any workaround for this?

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
:)
 
V

Vasile

Hi Cindy,

Thank you for your reply.

Actually what I was trying to achieve using that macro is
to do a mailmerge within a table (for every record from
the datasource a new row whitin the table is created).

Do you know any better way to achieve this?

Many thanks,
Vasile
 
C

Cindy M -WordMVP-

Hi Vasile,
Actually what I was trying to achieve using that macro is
to do a mailmerge within a table (for every record from
the datasource a new row whitin the table is created).

Do you know any better way to achieve this?
you might try using the DATABASE field; you'll find the
command in the Data toolbar. It may be that this field will
solve your problem and you won't need mail merge. Or, if
your goal is a one-to-many type of list (multiple
items/merge record) you'll find a sample here:

http://www.knowhow.com/Guides/DatabaseInfo/DatabaseInfo.htm

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
:)
 

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