Trying to detect Cancel in ShowPrinter
-
I found what I thought to be an easy way to shove a graphical VB form to a printer. It works fine when I call ShowPrinter and change the print quality and click OK.... But I don't know how to pick up the Cancel button click of the CommonDialog1.ShowPrinter and avoid printing. Here's the code: CommonDialog1.ShowPrinter Form1.PrintForm (need to detect cancel w/in CommonDialog1.ShowPrinter - branch around Form1.PrintForm if Cancel is pressed) Any ideas? Thanks in advance, \\Jim CommonDialog1.ShowPrinter jamesdturner@hotmail.com
-
I found what I thought to be an easy way to shove a graphical VB form to a printer. It works fine when I call ShowPrinter and change the print quality and click OK.... But I don't know how to pick up the Cancel button click of the CommonDialog1.ShowPrinter and avoid printing. Here's the code: CommonDialog1.ShowPrinter Form1.PrintForm (need to detect cancel w/in CommonDialog1.ShowPrinter - branch around Form1.PrintForm if Cancel is pressed) Any ideas? Thanks in advance, \\Jim CommonDialog1.ShowPrinter jamesdturner@hotmail.com
Try this: On Error GoTo ErrHandler CommonDialog1.CancelError = True CommonDialog1.ShowPrinter Form1.PrintForm Exit Sub ErrHandler: End Sub If you have existing Error Handling code the ErrHandler would look a little different: ErrHandler: If Err.Number <> 32755 Then '32755 is the Error Number for Cancel being selected 'Process Error as usual End If End Sub Andy Gaskell, MCSD