oWorddoc=Createobject("word.application")&& Create word object oWorddoc.documents.open(cfileName) * Set text file as data source for mailmerge oWorddoc.DisplayAlerts = 0 * datasource is tab delimited file created from a cursor. oWorddoc.Activedocument.MailMerge.OpenDataSource(m.lcSourceDoc) oWorddoc.Activedocument.MailMerge.Destination = 1 &&printer oWorddoc.Activedocument.MailMerge.Execute oWorddoc.documents.close(0) oWorddoc.application.quit release oWorddocThe problem I am having is that Word open up a "save as" prompt in which the user needs to name the file which is then save as a document imaging file .mdi. Once they hit the save button the program open up a document imaging screen and you can print the merged letters from it
>oWord.ActiveDocument.MailMerge.EditMainDocument >oWord.Visible = .f. >WITH oWord.ActiveDocument.MailMerge > .Destination = 0 && File > WITH .DataSource > .FirstRecord = 2 > .LastRecord = records_to_print > ENDWITH > .Execute(.t.) >ENDWITH >cWrdName = oWord.ActiveDocument.name > >*** Close ALL documents except the newly created file >doc_to_close = 1 >DO WHILE oWord.Documents.Count > 1 > nDoc = oWord.Documents(doc_to_close) > IF .NOT. cWrdName == nDoc.Name > nDoc.Close(0) > ELSE > doc_to_close = doc_to_close + 1 > ENDIF >ENDDO >>