Before print event - stop printing!

wilcowoods

Active Member
Joined
May 29, 2008
Messages
275
Excel 2003 - I know!

Easy one I think - I have a before print event procedure that (under certain conditions) is supposed to stop the sheet from printing. So if we get to this stage:

"If Ans <> vbOK then...."

how do I stop the sheet from printing...?

Any help appreciated.:)
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
What about exiting the sub routine, or cancel

if something here then
Exit Sub
Else
Something happens here
end if

or

Cancel = True
 
Upvote 0
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Ans = 99
If Ans <> vbOK Then
Cancel = True
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top