WayneFrank
Member
I have a problem related to saveas. In the following code, I merge a document and then save it on my hard drive. (This savved document is attached to an email in other code.
All this works fine. The problem is that if there are 100 letters merged and saved, then the user then has 100 open Word documents on their desktop. We do not want that, we just want them attached to the emails.
Is there a way to do saveas but not have the open Word document on the desktop?
Thanks
All this works fine. The problem is that if there are 100 letters merged and saved, then the user then has 100 open Word documents on their desktop. We do not want that, we just want them attached to the emails.
Is there a way to do saveas but not have the open Word document on the desktop?
Thanks
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(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.
/* Save the result of the Word merge. */
chWordApp:ActiveDocument:SaveAs("C:\Windows\Temp\" + save-as-name).
/* Brian from Progress. */
RELEASE OBJECT chDoc.
RELEASE OBJECT chMerge.
RELEASE OBJECT chNewDoc.
RELEASE OBJECT chWordApp.