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
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
Private WithEvents mPrinterExEvents As PrinterExEvents Private Sub Class_Initialize() Set mPrinterExEvents = PrintPreview.Events End Sub Private Sub mPrinterExEvents_ReportPrinted() MsgBox "Print done!" End Sub
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
Private Sub Command1_Click() Dim c As New Class1 c.PrintPreviewMyReport End Sub
Events
AfterShowingPageSetupDialog