Mail Merge - automatic from flat file - how to ignore messages

H

happy_cleo

Word 2002. I want to automate a mail merge e.g. Double click on document
name, document opens, merges data (from flat file), prints, closes. 1) I have
created a merge document (for invoices). 2) My (.txt) file has fewer data
fields than my header record. 3) I have an AutoOpen macro to merge the data.
4) Before the macro runs, Word asks for confirmation of the data delimiters
then gives me several message boxes to say RECORD 1 (etc) CONTAINED TOO FEW
DATA FIELDS.

Q) How do I stop the warning messages and the delimiter confirmation box
from appearing and thus stop the need for user intervention?

Thanks!
 
P

Peter Jamieson

You have to have the same number of fields in each data record as you do in
the header. I don't think anything will work until you fix that. I would
guess that you are trying to use the same header file with several data
files, each with a subset of the fields specified in the header file, but I
think you will have to change your approach. I would certainly consider
changing the format of the data source or using some preliminary code to
import the data into a single structure (perhaps an Access table), but if
that is not feasible I would consider starting with a main document that has
neither a header nor a data file attached, and attach both programmatically.

As far as the delimiters are concerned, what happens depends on the
delimiter, the method Word uses to connect to the data, and whether Word is
able to decide what the delimiters are (it may of course get it wrong). If
you are using header files, use the same delimiter as in the data file (but
even that may not be enough). If you are using OLEDB or the internal text
converter to connect tot he data, there is no way to specify the delimiter
programmatically. If you are using ODBC, you may be able to specify the
field delimiter in the SCHEMA.INI file that you can create by configuring
the appropriate ODBC DSN, but you cannot use a record delimiter other than
CRLF (or similar).

Peter Jamieson
 

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