View Single Post
  #3   Report Post  
Posted to microsoft.public.word.newusers
Bo Rasmussen
 
Posts: n/a
Default Mail merge as seperate files.

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-" wrote in message
news:VA.0000b94b.008f42fc@speedy...
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 :-)