Is there a way to print a letter with several address pulled from an access database. Something similar to mailmerge in word. I hope someone can help. Please!!!
Friend Sub PrintLetters(intTotalPages As Integer)
m_strCurrentProcedure = "PrintLetters"
On Error GoTo ErrorHandler
Dim cnPrintLetterAux As New ADODB.Connection
Dim strConnection As String
Set WordPrint = New Word.Application
With WordPrint
.Documents.Add App.Path & "\PrintTemplate.dot"
With .ActiveDocument.MailMerge
.OpenDataSource Name:=App.Path & "\SDMLetterAux.mdb", LinkToSource:=True, AddToRecentFiles:=False, Connection:="TABLE LetterDetails"
.DataSource.FirstRecord = 1
.DataSource.LastRecord = intTotalPages
.Destination = wdSendToPrinter
.Execute
End With
End With
frmDebtorList.pgbProgress.Value = frmDebtorList.pgbProgress.Value + 1 'The 2 is for the fax and printer which are already complete
WordPrint.Quit wdDoNotSaveChanges
Exit Sub
ErrorHandler:
If Err.Number = 4198 Then 'cancel on the print dialog was clicked
WordPrint.Quit wdDoNotSaveChanges
MsgBox "Printing cancelled", , "Cancelled"
Else
MsgBox Err.Number & " - " & Err.Description & vbCrLf & "An error occurred in " & m_CurrentModule & "." & m_strCurrentProcedure & vbCrLf & "Please see the vendor."
End If
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.