mailmerge ends prematurely w/o error

C

christopher.allen

I have Word VBA code that basically:

opens a main doc
for each *.txt
opens it as a datasource
mailmerges it
saves it
Adobe ConvertToPDF
closes it
next

Sometimes, the mailmerge ends prematurely without merging all the
records. No indication at all of any problem. These are 500-record
datasources, the first record being the header info.

What really bothers me is that sometimes it works, sometimes it doesn't.
Sometimes it'll do this on smaller datasource files too. It occurs on
the mailmerge, not the ConverToPDF, sometimes on the first datasource.

Anyone experienced this? I'll be happy to supply more details if you want.

Word 2000, Windows XP SP2. Also reproduced with Word 2003.
 
P

Peter Jamieson

Just an observation... my own experience of doing this kind of thing (which
is rather outdated now) is that Word probably has at least one memory leak
that will appear no matter how you split up a large merge. It may be worth
trying to do multiple merges using a script that starts word, does the
merge, closes word and so on, but that's not particularly easy either.

Unless you are having problems with specific .txt files...

Peter Jamieson
 
C

christopher.allen

Thanks for your comments, I've tried the one-merge-per-invocation and
that helps.

I'm running Word from a perl script, and I thought there might be some
funny business going on with this setup, another reason I tried the
one-merge-per-invocation thing. The perl script basically does this,
once per data source file:

my $wrd = Win32::OLE->new('Word.Application');
$wrd->Run($MACRO);
$wrd->Quit();

Another thing I thought of: my system has both Word 2000 and 2003
installed, so I'm wondering if there's any interference between the two
installations. Running on a single-install system seems to help.

Also, each of my data source files contains the header record as the
first line. Does this ring any bells?

Thanks again.
 
P

Peter Jamieson

Also, each of my data source files contains the header record as the first
line. Does this ring any bells?

Not really, but it's possible that WOrd is using different methods to read
the .txt files - with Word 2003 it would be a choice between its internal
text converter, and an OLE DB provider. Although I would expect that it
would /always/ read the same file using the same method, if your file
content is changing over time, that method might change for each file from
merge to merge. Precisely why that would cause a problem I do not know, but
perhaps for example one method is leakier than another.

However, the chances are that that's a red herring.
 

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