ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Controlling the 'cancel' button in xldialogprint (https://www.excelbanter.com/excel-programming/340215-controlling-cancel-button-xldialogprint.html)

JNW

Controlling the 'cancel' button in xldialogprint
 
I've got a button at the bottom of a sheet called 'Print'. Logically one
would only push that button when they really wanted to print the sheet, but
some click and are suprised when the print dialog comes up.

After a logical person clicks the button on purpose and prints the form a
message box asks to verify if the sheet printed before finishing the code.
The problem is that if you click cancel in the print dialog the code
continues to the print confirmation.

I could add a msgbox before opening 'Print' asking if they really want to
print, but sometimes people even get past that.

Is there any way for me to say: "if cancel button in print dialog is true,
then exit sub"?

Thank you

Tom Ogilvy

Controlling the 'cancel' button in xldialogprint
 
res = application.Dialogs(xlDialogPrint).show
if res = False then
' dialog cancelled
exit sub
End if

--
Regards,
Tom Ogilvy

"JNW" wrote in message
...
I've got a button at the bottom of a sheet called 'Print'. Logically one
would only push that button when they really wanted to print the sheet,

but
some click and are suprised when the print dialog comes up.

After a logical person clicks the button on purpose and prints the form a
message box asks to verify if the sheet printed before finishing the code.
The problem is that if you click cancel in the print dialog the code
continues to the print confirmation.

I could add a msgbox before opening 'Print' asking if they really want to
print, but sometimes people even get past that.

Is there any way for me to say: "if cancel button in print dialog is true,
then exit sub"?

Thank you





All times are GMT +1. The time now is 06:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com