mail merge not working.. :(

seductive

Member
i everyone.. i have a problem about mail merge...
im using this code..
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("D:\sample.doc",,YES,FALSE).

/* set Mail Merge object */
chMerge = chDoc:MailMerge.

/* open the data source */
chMerge:OpenDataSource("D:\sampletxt.txt").
chMerge:SuppressBlankLines = FALSE.

/* merge target is a NEW word Doc */
chMerge:Destination = {&wdSendToNewDocument}.

/* Run merge */
chMerge:EXECUTE.

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

RELEASE OBJECT chDoc.
RELEASE OBJECT chMerge.
RELEASE OBJECT chNewDoc.
RELEASE OBJECT chWordApp.


how do i hide the template document??
 
Top