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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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,222,405
Messages
6,165,865
Members
451,988
Latest member
boo203

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