Error when using word mailmerge in the background

Len Kramer

New Member
I'm using some code I found to perform a word mailmerge in the background. This merges a word template.doc with a datafile.csv and creates a document per datarecord and saves it as .pdf. It has a surrounding FOR EACH loop on a temp-table with the savenames, datafilenames etc.
   /* Start word */
   CREATE "Word.Application" chWord.
   chWord:DisplayAlerts = FALSE.
<FOR EACH logic>

   /* Open templatedocument */
   chDocument = chWord:Documents:OPEN (ttDocSel.doc_tmp, , TRUE, FALSE).   /* 2.00 */

   /* Start mailmerge */
   chMerge = chDocument:MailMerge.
   chMerge:OpenDataSource (lvaDataFile).
   chMerge:SuppressBlankLines = TRUE.
   chMerge:Destination = 0.               /* 0-wdSendToNewDocument; 1-wdSendToPrinter; 2-wdSendToEmail; 3-wdSendToFax */
   chMerge:DataSource:FirstRecord = lviFirstRecord.
   chMerge:DataSource:LastRecord = lviLastRecord.
   chNewDoc = chWord:ActiveDocument.
   chNewDoc:FIELDS:UPDATE. /* Fails with error 5890. Only when size of datafile exceeds a size of apx 30 kb and only when run on AppServer */

(Save as pdf coding is left out here, that's not the problem)

  <Object close en remove>
This works fine as long as the datafile size is limited to something around 30 Kb. That is, when the program is run on a remote AppServer. When I run it on the client session the problem does NOT occur (but it takes quite some time to finish when it involves a couple of thousands of documents).

The appserverlog shows this:
[19/05/21@20:45:20.121+0200] P-008284 T-004116 1 AS -- (Procedure: 'MergeToPDF.P' Line:1355) Fout terwijl Component Property/Method werd benaderd: FIELDS.
[19/05/21@20:45:20.121+0200] P-008284 T-004116 1 AS -- (Procedure: 'MergeToPDF.P' Line:1355) Call was rejected by callee.

[19/05/21@20:45:20.121+0200] P-008284 T-004116 1 AS -- (Procedure: 'MergeToPDF.P' Line:1355) Error code: 0x80010001 MergeToPDF.P (5890)

So the error occurs when invoking the FIELDS:UPDATE method.

Does this error relate to the filesize in some way ?
Is there a setting in the word application that imposes the limit on the datafile size and if so, can that be adjusted?
Last edited by a moderator:


Active Member
True, that does not really solve anything.

It is many years since I used Word mail merge but did not recall very large file sizes causing a problem.

If any help I have attached three mail merge examples which I had downloaded in the past. What is noticeable is none of them appear to use the Fields:Update option. However, this could be due to them being very old.