I am creating reports usint Word merge. The code opens Word, merges the data and saves the report and opens the merged document. When the document is closed by the user, the instance of WINWORD.EXE continues to run in the Task Manager with no visible document in the task bar. "End Process" in the Task Manager will close it. How can I kill that instance with code?
Here is my code:
ThanksCode:Dim strFileNamePath As String Dim strFileSavePath As String Dim wdApp As Word.Application 'Dim WordDoc As Object 'Dim strActiveDoc As String 'Dim strDataSourcePath strFileNamePath = "C:\Users\Wayne\Documents\Civilsys\Civis Sys v6\RptMergeTemplates\Merge-Receipt.docx" strFileSavePath = "C:\Users\Wayne\Documents\Civilsys\Civis Sys v6\RptMergeTemplates\Receipt.docx" 'strDataSourcePath = "C:\Users\Wayne\Documents\Civilsys\Civis Sys v6\CivilSysReceipts.accdb" Set wdApp = CreateObject("Word.Application") wdApp.Documents.Open strFileNamePath 'Open Document in Word wdApp.Visible = False wdApp.ActiveDocument.MailMerge.OpenDataSource _ Name:=Application.CurrentProject.FullName, _ OpenExclusive:=False, _ LinkToSource:=True, _ Connection:="TABLE tblPrintReceiptTemp", _ SQLStatement:="SELECT tblPrintReceiptTemp.* FROM tblPrintReceiptTemp;" wdApp.ActiveDocument.MailMerge.Execute wdApp.ActiveDocument.SaveAs strFileSavePath wdApp.Documents.Open strFileSavePath 'Open saved, merged document Set wdApp = Nothing
Wayne


Word Merge Report
Reply With Quote



