Automated Mailmerge of comma separated file

M

Mike Trout

I've got an application that uses OLE auto. to open a word doc, make it a
mailmerge doc, attach a previously created data file (in sdf format - comma
separated, quote delimited) merge and print. This works well as long as the
data file and/or the document have already been merger. Otherwise I get the
dialog box asking me what the separators are. I'd need to avoid this.

The word doc is, for example, "letter1.doc", the data source is
"mergedata.sdf", and the (trimmed of the error checking, etc...) code I use
is (word is assumed to be already open here):

oword.documents.open( "letter1.doc", false, true)
oword.activedocument.mailmerge.maindocumenttype = 0
omerge = oword.activedocument.mailmerge
omerge.opendatasource( "mergedata.sdf", "wdopenformattext", false, true,
true, false, "", "", false, "", "", "DSN=All files", "" )
omerge.execute( false )

I get the separater dialog box in the omerge.opendatasource line I believe.
What changes can I make to have it automatically select commas & quotes?

TIA
 
H

Helmut Weber

Hi Mike,
my advice in order to get rid of that and maybe some other
complications, is to set up a document template and connect it to
the datasource. Of course, this datasource has always to have the same
name and location. But that is rather an advantage, as is offers still
more possibilities by automating the export from the database. Keeping
the export-file (sdf) is of little use, as the export can be repeated
any time.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
 
M

Mike Trout

So, basically there's no way to programmatically give Word that information,
and I need to have the datasource attached to the document (interactively so
I can go through those dialogs) prior to calling the merge, is this correct?

I was hoping there was some option in the opendatasource() method to specify
that, because there are already 75 or 80 documents previously created (and
more to go) that each need to have one of about 10 different datasources
attached... I was hoping I could do that programmatically so I could make
it easier on the users. (trust me that it needs to be easier on the users -
they ask me every time how to use the letterhead template I created for
them, after they have typed the whole document... They're dense when it
comes to "Open the template you want to use FIRST!")

Thanks for your information, Helmut.

Does anyone know if there's an option in the opendatasource() method that
will let me bypass those messages? Or maybe a different file format? (I"m
using sdf files, but I can output other formats if necessary - I can change
the subroutines to create the datasource...)
 
H

Helmut Weber

Hi Mike,
to give Word the required information should be possible, I think.
But I don't know how, and I wonder, if it's worth the effort to find
out. In case your database-program can write excel-files, this would
be my first choice. Even with DBase IV there should be no question as
to what should be used as a delimiter, though to establish the
connection my be tricky.
Regarding Your users, I started my so called professional career
in a publishing house, where some editors successfully refused
to use a typewriter...
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word XP, Win 98
 

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