Print current page only from toolbar?

Margate

New Member
Joined
Mar 15, 2013
Messages
21
I have made a sheet that has been divided up into 40 pages using page breaks. On this sheet there are 40 different buttons that have macros attached to them that will print a certain page depending on what button is pressed. This works great until the user presses the print icon along the tool bar and 40 pages print out!

Is there anything that I can do to either disable this icon or preferably only print the current page when it is pressed?

Thank you very much for any help, I have no idea how to resolve this!:eek:
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
To disable to PRINT icon in the toolbar, put this code in a workbook_open module
Code:
Application.CommandBars.FindControl(ID:=2521).Enabled = False

You will also need to to reinstate it when you close the workbook, use
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.CommandBars.FindControl(ID:=2521).Enabled = True
End Sub
 
Upvote 0
Hello Michael,

I put the following into a Module:

Private Sub Workbook_Open()
Application.CommandBars.FindControl(ID:=2521).Enabled = False
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars.FindControl(ID:=2521).Enabled = True
End Sub


I then came out of the workbook, saved, re-opened and pressed the print icon but it printed 40 pages.
Do you have any idea what I have done wrong? I am not very good with Macros and just about know where to find a Module (Alt+F11)....!

Thank you very much for your help....

Margate.
 
Upvote 0
What version are you using ??
 
Upvote 0
Ok, both codes will work for 2003, but make sure you put them in "this Workbook" module
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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