Forcing the Print Dialog box even when the user hit the print icon on the toolbar

BPtexan

New Member
Joined
Jul 4, 2009
Messages
24
I have a program that I'm trying to make printing easier. I'm trying to create a macro that will automatically bring up the print dialog box when the user hits ctrl+p or uses the icon on the toolbar.

I know the command to bring up the print dialog box:
Application.Dialogs(xlDialogPrint).Show

I also know how to access the before print do ___ in the vba editor.

The problem is by running the xldialogprint command, the process starts over in the before print action. How can I avoid this? Thanks!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Perhaps;
Code:
[COLOR="Blue"]Private[/COLOR] [COLOR="Blue"]Sub[/COLOR] Workbook_BeforePrint(Cancel [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR])
    Cancel = [COLOR="Blue"]True[/COLOR]
    [COLOR="Blue"]With[/COLOR] Application
        .EnableEvents = [COLOR="Blue"]False[/COLOR]
        .Dialogs(xlDialogPrint).Show
        .EnableEvents = [COLOR="Blue"]True[/COLOR]
    [COLOR="Blue"]End[/COLOR] [COLOR="Blue"]With[/COLOR]
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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