Ignore Print-Previews for Workbook_BeforePrint

Dragon_SDC

Board Regular
Joined
Aug 17, 2002
Messages
56
Hello,

Is there any way (short of adding a confirmation box) to stop the Workbook_BeforePrint macro from activating?

Also, if I remember correctly the macro also runs when one uses File->Print, even though it brings up a Printer option-selection window, and a cancelation is still possible.

Any ways to get round that?

Thanks in advance!
This message was edited by Dragon_SDC on 2002-08-27 06:33
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Dragon-SDC,

In general we can use the Application.EnableEvents to prevent events to be executed.

We can also create the events App_BeforePrint in a classmodule which replace the general Workbook_BeforePrint.

However, You may also consider to use the variable Cancel by setting it to True which prevent the actions in the events.

<PRE>
Private Sub<FONT color=blue> Workbook</FONT>_BeforePrint(Cancel<FONT color=blue> As</FONT> <FONT color=blue>Boolean</FONT>)



<FONT color=blue>If </FONT>IsEmpty(Range("A1")) Then

Cancel =<FONT color=blue> True</FONT>

<FONT color=blue>Else</FONT>

<FONT color=#ff0000> 'Your code
</FONT>
<FONT color=blue>End If</FONT>



<FONT color=blue>End Sub</FONT>


</PRE>

Please let us more about it,

HTH,
Dennis
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

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