I have a mail merge button with the following code.
Dim objWord As Word.Document
Set objWord = GetObject("G:\MSAPPS\Share\Dueshor2.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Northwind database.
objWord.MailMerge.OpenDataSource _
Name:="G:\MSAPPS\Share\NMember.mdb", _
LinkToSource:=True, _
Connection:="Query qryinvoice", _
SQLStatement:="Select * from [qryinvoice]"
' Execute the mail merge.
objWord.MailMerge.Execute
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
objWord.Application.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
objWord.Application.Visible = False
At the end word is not visible and appears to be closed but when you try to shut down it asks you if you want to save the changes to the word document. How can I close word with out saving it in vb code. It seems that "SaveChanges:=wddonotsavechanges" is not working.
Dim objWord As Word.Document
Set objWord = GetObject("G:\MSAPPS\Share\Dueshor2.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Northwind database.
objWord.MailMerge.OpenDataSource _
Name:="G:\MSAPPS\Share\NMember.mdb", _
LinkToSource:=True, _
Connection:="Query qryinvoice", _
SQLStatement:="Select * from [qryinvoice]"
' Execute the mail merge.
objWord.MailMerge.Execute
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
objWord.Application.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
objWord.Application.Visible = False
At the end word is not visible and appears to be closed but when you try to shut down it asks you if you want to save the changes to the word document. How can I close word with out saving it in vb code. It seems that "SaveChanges:=wddonotsavechanges" is not working.