View Single Post
  #2   Report Post  
Posted to microsoft.public.word.newusers
Cindy M -WordMVP-
 
Posts: n/a
Default Mail merge as seperate files.

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