Using CommonDialog inVB6
In using CommonDialog.ShowPrinter, the dialog box to select printer will show. How will my program knows if the user hit CANCEL instead of PRINT? I tried using ON ERROR, but does not work.
Thanks in Advance
Web Development
In using CommonDialog.ShowPrinter, the dialog box to select printer will show. How will my program knows if the user hit CANCEL instead of PRINT? I tried using ON ERROR, but does not work.
Thanks in Advance
by sl-campbell
On Error GoTo Err_Handler
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen
'Code to print
ExitProceedure:
Exit Sub
Err_Handler:
Resume ExitProceedure
by sl-campbell
by nicemaster
The common dialog box has a property called "CancelError". If you set this to true, the common dialog box will raise an error when they click cancel. Thay way you can know. However you must handle this error:
Sub CmdPrint_OnClick()
On error goto ErrorHandler 'Cancel error raised
CommonDialog1.showPrinter
Msgbox "Thank you for printing."
Exit sub
ErrorHandler:
'If you get here, the user has cancelled
msgbox "You pressed cancel!"
End Sub
I hope that helps, good luck!
by nicemaster
by nicemaster
This discussion is closed to new replies.
Sort by Trending