Mail merge as seperate files.

  • Thread starter Thread starter Bo Rasmussen
  • Start date Start date
B

Bo Rasmussen

Hi,

I would like to be able to save individual files (i.e. one per record in the
datasource) from a mail merge. Using VBA it is relatively easy to obtain
each merge result (record) as a section which I can easily save as a file.
My problem is that I want the filename to be that of one of the merge
fields. It seems however that in the merge result all fields are gone - now
they are just pure text. So there is no way I can easily reference them.
Does anybody know how to do this?

Kind regards
Bo Rasmussen
 
Hi Bo,
I would like to be able to save individual files (i.e. one per record in the
datasource) from a mail merge. Using VBA it is relatively easy to obtain
each merge result (record) as a section which I can easily save as a file.
My problem is that I want the filename to be that of one of the merge
fields. It seems however that in the merge result all fields are gone - now
they are just pure text. So there is no way I can easily reference them.
Does anybody know how to do this?
The only way you could to this would be to access the main merge document in
your code and loop through the records in order to pick up the fields. use
doc.MailMerge.DataSource.ActiveRecord = [number or WD-constant] to
- go to the first record at the beginning
- move to the next record in each part of the loop

To get the value of a particular field
doc.MailMerge.DataSource.DataFields("Name").Value

Note that this could be excruciatingly slow if a lot of records are involved.
In that case, it might make more sense to access the data source directly
using an ADO connection (assuming the source isn't a Word table).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :-)
 
Hi Cindy,

I was hoping it would be easier. Actually my idea was to apply some style to
the mergefield that should be used as filename. Then I could use a StyleRef
field to obtain the value. But everything disappears in the merge result -
both style and StyleRef field. Why does that happen?

Kind regards
Bo


Cindy M -WordMVP- said:
Hi Bo,
I would like to be able to save individual files (i.e. one per record in the
datasource) from a mail merge. Using VBA it is relatively easy to obtain
each merge result (record) as a section which I can easily save as a file.
My problem is that I want the filename to be that of one of the merge
fields. It seems however that in the merge result all fields are gone - now
they are just pure text. So there is no way I can easily reference them.
Does anybody know how to do this?
The only way you could to this would be to access the main merge document in
your code and loop through the records in order to pick up the fields. use
doc.MailMerge.DataSource.ActiveRecord = [number or WD-constant] to
- go to the first record at the beginning
- move to the next record in each part of the loop

To get the value of a particular field
doc.MailMerge.DataSource.DataFields("Name").Value

Note that this could be excruciatingly slow if a lot of records are involved.
In that case, it might make more sense to access the data source directly
using an ADO connection (assuming the source isn't a Word table).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)


This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
 
There's an add-in available from my web site that provides this function
http://www.gmayor.com/individual_merge_letters.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Bo said:
Hi Cindy,

I was hoping it would be easier. Actually my idea was to apply some
style to the mergefield that should be used as filename. Then I could
use a StyleRef field to obtain the value. But everything disappears
in the merge result - both style and StyleRef field. Why does that
happen?

Kind regards
Bo


Cindy M -WordMVP- said:
Hi Bo,
I would like to be able to save individual files (i.e. one per
record in the datasource) from a mail merge. Using VBA it is
relatively easy to obtain each merge result (record) as a section
which I can easily save as a file. My problem is that I want the
filename to be that of one of the merge fields. It seems however
that in the merge result all fields are gone - now they are just
pure text. So there is no way I can easily reference them. Does
anybody know how to do this?
The only way you could to this would be to access the main merge
document in your code and loop through the records in order to pick
up the fields. use doc.MailMerge.DataSource.ActiveRecord =
[number or WD-constant] to
- go to the first record at the beginning
- move to the next record in each part of the loop

To get the value of a particular field
doc.MailMerge.DataSource.DataFields("Name").Value

Note that this could be excruciatingly slow if a lot of records are
involved. In that case, it might make more sense to access the data
source directly using an ADO connection (assuming the source isn't a
Word table).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)


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