MailMerge with datasource=csv

C

Chris

Hi,

I created a mailmerge template. Now I wanne feed the template
with a csv file. Is it possible to access a csv file with the
CreateDataSource
method ? Code sample ?
Building a large word datasource is really slow. Or MSAccess is a better
solution ?


Thanks in advance,
Chris
 
D

Doug Robbins - Word MVP

There is no problem with using a .csv file as the data source for a mail
merge. Are you wanting to do this programmatically?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

Chris

I will generate the csv file programmatically.
Afterwards I will feed a mail merge template with the csv file. This should
also done
programmatically.
Someone has a code sample which adds creates a datasource to a csv file ?


Chris
 
C

Chris

I think I got it.
I use the OpenDataSource(..) method and refer to the csv file.
The Header in the csv file is equal named to the merge fields in my
template.

But when a merge field does not match to the data source a dialog pops up.
How can I avoid that ? Or how can I check, if the datasource matches the
merge fields ?


Chris
 
D

Doug Robbins - Word MVP

You should be able to write some code to iterate through the name of the
merge fields in the main document and see if they are included in the fields
in the data source, but what are you going to do if they aren't there? The
user is going to be faced with the same issue and I think that all you will
have done with the code is re-invent the wheel that is causing the dialog to
pop up telling you that a field does not match.

I suppose if it was a single field that did not match, as you interate
through the merge fields in the main document, you could eliminate the
matching ones from the data source fields under consideration so you would
end up with one merge field from the main document that did not match the
remaining field from the data source and then change the field in the main
document. That will not work however if there remained more than one field
in the data source, any one of which could be the one to match with the
field in the main document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

Chris

Hi Doug,

the problem I am facing with:
I have a server task that generates mail merge letters for customers with
custom templates. When some merge fields does not match with the datasource
the generating is blocking my server process. Therefore it is a good idea
to check the merge field in the template before starting the generation. If
some
merge fields does not match throwing an error is a good issue.


Chris
 

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