Question Variable in header of Word merge.

WayneFrank

Member
I have asked this before. I would be most grateful if I could see a Progress example of how to do this. Thanks.

I am doing a Word merge from a Progress program. When I put a merge variable in the heading, the merge does not put a value in it. The merge variables in the body work fine.
Funny thing is, if I use the same document and run the merge just from Word, the variable in the header gets its value just fine. From the Progress program, it skips the variable int eh heading but does the variables in the body.
 
Here is the code I am using.

DEFINE VARIABLE chWordApp AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chDoc AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chMerge AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chNewDoc AS COM-HANDLE NO-UNDO.

&GLOBAL-DEFINE wdSendToNewDocument 0

CREATE "Word.Application" chWordApp.
chWordApp:ScreenUpdating = TRUE.
chWordApp:visible = FALSE.
chWordApp:displayAlerts = FALSE.

/* open the template document */
chDoc = chWordApp:documents:OPEN(merge-form,,YES,FALSE).
/* set Mail Merge object */
chMerge = chDoc:MailMerge.
/* open the data source */
chMerge:OpenDataSource(input-file).
/* set merge file to correct type */
chMerge:MainDocumentType = merge-file-type.
chMerge:SuppressBlankLines = FALSE.
/* merge target is a NEW word Doc */
chMerge:Destination = {&wdSendToNewDocument}.
/* Run merge */
chMerge:EXECUTE.
/* Close merge form */
chdoc:CLOSE(FALSE).

/* get handle to new document (the merged one) */
chNewDoc = chWordApp:ActiveDocument.
chNewDoc:fields:update.
chWordApp:visible = TRUE.
chWordApp:ACTIVATE.

RELEASE OBJECT chDoc.
RELEASE OBJECT chMerge.

RELEASE OBJECT chNewDoc.
RELEASE OBJECT chWordApp.
 
Back
Top