Home > BSPrinter documentation > Reference

PrinterExEvents object


Auxiliary object used to receive events from a IPrinterEx object.

Sample usage in a Form:

Private WithEvents mPrinterExEvents As PrinterExEvents

Private Sub Form_Load()
    Set mPrinterExEvents = PrintPreview.Events
End Sub

Private Sub mPrinterExEvents_ReportPrinted()
    MsgBox "Print done!"
End Sub


This is only the code for handling the events, for a working sample add a PrintPreview control and a CommandButton to a form and paste this code:

Private WithEvents mPrinterExEvents As PrinterExEvents

Private Sub Command1_Click()
    PrintPreview1.ShowPreview
End Sub

Private Sub Form_Load()
    Set mPrinterExEvents = PrintPreview.Events
End Sub

Private Sub mPrinterExEvents_ReportPrinted()
    MsgBox "Print done!"
End Sub

Private Sub PrintPreview1_PrepareReport(Cancel As Boolean)
    Printer.Print "Hello world."
End Sub


Sample usage in a Class module:

Private WithEvents mPrinterExEvents As PrinterExEvents

Private Sub Class_Initialize()
    Set mPrinterExEvents = PrintPreview.Events
End Sub

Private Sub mPrinterExEvents_ReportPrinted()
    MsgBox "Print done!"
End Sub


This is only the code for handling the events, for a working sample add this code to a Class module:

Private WithEvents mPrinterExEvents As PrinterExEvents

Private Sub Class_Initialize()
    Set mPrinterExEvents = PrintPreview.Events
End Sub

Public Sub PrintPreviewMyReport() ' This is the method that will be called to show the print preview dialog with the report
    PrintPreview.ShowPreview
End Sub

Private Sub mPrinterExEvents_PrepareReport(Cancel As Boolean)
    MyPrintingRoutine
End Sub

Private Sub mPrinterExEvents_ReportPrinted()
    MsgBox "Print done!"
End Sub

Private Sub MyPrintingRoutine()
    Printer.Print "Hello Word"
    ' continue with the printing code
End Sub


And add a CommandButton and this code to a form:

Private Sub Command1_Click()
    Dim c As New Class1
    
    c.PrintPreviewMyReport
End Sub


  • Events

  • Events

    AfterShowingPageSetupDialog
    AfterShowingPrinterDialog
    AuxiliaryButtonClick
    BeforePrint
    BeforePrintingPageNumbers
    BeforeShowingFormatDialog
    BeforeShowingPageSetupDialog
    BeforeShowingPrinterDialog
    CurrentPrinterDefaultSettingChange {PrinterExEvents object}
    DefaultPrinterChange {PrinterExEvents object}
    EndDoc
    GetLocalizedText
    OrientationChange
    PaperSizeChange
    PrepareReport
    ReportPrinted
    ScaleChange
    StartDoc
    StartPage