Public Function FilePrintDlgProc(rprnDlg As _
CommonDialog, rRTF As _
RichTextBox) As Boolean
On Local Error GoTo Error_Handler:
With rprnDlg
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If rRTF.SelLength = 0 Then
.Flags = .Flags + cdlPDAllPages
Else
.Flags = .Flags + cdlPDSelection
End If
.ShowPrinter
' Genom att skriva detta, kommer programmet att
' fortsätta, även om det blir något fel.
On Local Error Resume Next
Printer.Print ""
rRTF.SelPrint Printer.hDC
Printer.EndDoc
FilePrintDlgProc = True
End With
Exit Function
Error_Handler:
If Err <> cdlCancel Then
MsgBox "Error " & Err & "; " & Error
End If
End Function