Heres some code i wrote 2 years ago
Friend Sub PrintLetters(intTotalPages As Integer)
m_strCurrentProcedure = "PrintLetters"
On Error GoTo ErrorHandler
Dim cnPrintLetterAux As New ADODB.Connection
Dim strConnection As String
strConnection = "DSN=DebtManager"
'cnPrintLetterAux.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51; Data Source=" & App.Path & "\SDMLetterAux.mdb"
cnPrintLetterAux.ConnectionString = strConnection
cnPrintLetterAux.Open
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
Good Luck
FW