I have code that will use a query "MemberKIt" and merge it with word, then it will uncheck the MemberKit check box on the Member form and puts a check on the sent box. My Problem is after the merge is done and the letters print out word will ask if I want to save the letter and then will ask if I want to save the form letter. How can I just have word merge, print and close with out asking to save for each document????
Here is My Code: Any help would be great.
Private Sub cmdMemberKit_Click()
Dim MemKit As Recordset
Dim objWord As Word.Document
Dim Msg, Style, Response
Msg = "Member Invoice Letter, do you want to print? If yes please do not save when asked"
Style = vbYesNo + vbDefaultButton2
Response = MsgBox(Msg, Style)
If Response = vbNo Then Exit Sub
If Response = vbYes Then
Set MemKit = CurrentDb.OpenRecordset("MemberKit")
Do While Not MemKit.EOF
Set objWord = GetObject("G:\MSAPPS\Share\MemLet1.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Members database.
objWord.MailMerge.OpenDataSource _
Name:="G:\MSAPPS\Share\NMember.mdb", _
LinkToSource:=True, _
Connection:="Query MemberKit", _
SQLStatement:="Select * from [MemberKit]"
' Execute the mail merge.
objWord.MailMerge.Execute
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
MemKit.Edit
MemKit("MemberKit") = 0
MemKit("KitSent") = 1
MemKit.Update
MemKit.MoveNext
Loop
Set MemKit = Nothing
objWord.Application.ActiveDocument.Close Savechanges:=wdDoNotSaveChanges
objWord.Application.Quit
End If
End Sub
Here is My Code: Any help would be great.
Private Sub cmdMemberKit_Click()
Dim MemKit As Recordset
Dim objWord As Word.Document
Dim Msg, Style, Response
Msg = "Member Invoice Letter, do you want to print? If yes please do not save when asked"
Style = vbYesNo + vbDefaultButton2
Response = MsgBox(Msg, Style)
If Response = vbNo Then Exit Sub
If Response = vbYes Then
Set MemKit = CurrentDb.OpenRecordset("MemberKit")
Do While Not MemKit.EOF
Set objWord = GetObject("G:\MSAPPS\Share\MemLet1.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Members database.
objWord.MailMerge.OpenDataSource _
Name:="G:\MSAPPS\Share\NMember.mdb", _
LinkToSource:=True, _
Connection:="Query MemberKit", _
SQLStatement:="Select * from [MemberKit]"
' Execute the mail merge.
objWord.MailMerge.Execute
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
MemKit.Edit
MemKit("MemberKit") = 0
MemKit("KitSent") = 1
MemKit.Update
MemKit.MoveNext
Loop
Set MemKit = Nothing
objWord.Application.ActiveDocument.Close Savechanges:=wdDoNotSaveChanges
objWord.Application.Quit
End If
End Sub