Hi All
The following code prints off one copy of all the letters and then another copy of all the letters but i want it to print two copies of each letter together. I hope it makes sense. I want somebody to modify the code accordingly.
The following code prints off one copy of all the letters and then another copy of all the letters but i want it to print two copies of each letter together. I hope it makes sense. I want somebody to modify the code accordingly.
Code:
Sub WordSetup(fnTemplate As String, fnBackGroundPic As String, txtbox As String)
On Error Resume Next
MsgBox txtbox
Dim strworkbookname As String
strworkbookname = "J:\System1.mdb"
Set WordApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'Launch a new instance of Word
Err.clear
On Error GoTo ErrorHandler
Set WordApp = CreateObject("Word.Application") 'New Word.Application
End If
WordApp.Documents.Add (fnTemplate)
Set WordDoc = WordApp.ActiveDocument
'WordApp.Visible = True
InsertHeaderLogo (fnBackGroundPic)
With WordDoc.MailMerge
.MainDocumentType = 0
.Destination = 1
.OpenDataSource _
Name:=strworkbookname, _
AddToRecentFiles:=False, _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="Data Source=" & strworkbookname & ";Mode=Read", _
sqlstatement:="SELECT * FROM `tblmaster` where Printpoolno='" & txtbox & "'"
'MsgBox sqlstatement
.Execute
.Execute
.Parent.Close 0
End With
MsgBox "The letters have been printed off module"
ExitErrorHandler:
Exit Sub
ErrorHandler:
MsgBox "Error (" & Err.Number & ") : " & Err.Description & vbCrLf & vbCrLf & "Exiting procedure - WordSetUp", vbCritical
Resume ExitErrorHandler
End Sub