On error resume next
printer.print "" richtext.selprint printer.hdc printer.enddoc 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 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 |