Private Function PrintPages(ByVal strMsgBoxCaption As String, _
ByVal lngStartPage As Long, _
ByVal lngNumPages As Long) As Boolean
On Error GoTo PrintPages_Error
Dim lngPageNum As Long
Dim boolCantPrintObject As Boolean
Dim boolPrintPage As Boolean
Dim strMsgBoxPrompt As String
Dim intMsgBoxStyle As Integer
PrintPages = True
For lngPageNum = lngStartPage To lngNumPages Step 2
If PrintPage(lngPageNum, _
boolCantPrintObject, _
boolPrintPage) = False Then
Exit For
End If
Next lngPageNum
PrintPages_Exit:
If boolCantPrintObject = True Then
PrintPages = False
intMsgBoxStyle = gconOKExcStyle
strMsgBoxPrompt = "Der Bericht kann nicht gedruckt" & gconShall & gconTwofoldCrLf & _
"Bitte prüfen Sie, ob der Standarddrucker angeschlossen und/oder eingeschaltet ist."
ElseIf boolPrintPage = False Then
PrintPages = False
intMsgBoxStyle = gconOKInfStyle
strMsgBoxPrompt = "Der Druckauftrag wurde abgebrochen." & gconTwofoldCrLf & _
"Sofern sich noch Seiten in der Druckwarteschlange befinden, werden diese zum Drucker gesendet."
End If
If PrintPages = False Then
Call MsgBox(strMsgBoxPrompt, _
intMsgBoxStyle, _
strMsgBoxCaption)
End If
Exit Function
PrintPages_Error:
Resume PrintPages_Exit
End Function
Private Function PrintPage(ByVal lngPageNum As Long, _
ByRef rboolCantPrintObject As Boolean, _
ByRef rboolPrintPage As Boolean) As Boolean
On Error GoTo PrintPage_Error
Const conCantPrintObject As Long = 2212
DoCmd.PrintOut acPages, lngPageNum, lngPageNum, acHigh, 1, True
PrintPage = True
PrintPage_Exit:
Exit Function
PrintPage_Error:
If Err.Number = conCantPrintObject Then
rboolCantPrintObject = True
Else
rboolPrintPage = False
End If
Resume PrintPage_Exit
End Function