I need to creat a Print Button

squallxgamer

New Member
Joined
Nov 10, 2017
Messages
7
Hello everyone! New here. I have used the forum and for the most part have always found answers and not needed to make a post. But alas the time has come.

I need to create for a file that has 2 sheets. I would like this button to open the dialog that allows for the printer to be selected and the number of pages. But I want it to auto select all pages to print. I also want to disable all other ways of printing so that only this button can be used.

Thanks for the help everyone.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
hi and welcome to your first question post.

i would consider making your own userform that only offers the options you want available and then print without showing the print dialog box. i dont think you are able to hack the standard dialog box
 
Upvote 0
I will have to look into the "Userform" as it is something I have never used before. Most everything I know has been learned as I have needed it. I have a specific document where there is two tabs . It is an hour by hour schedule used by employees to designate task for that hour. On the other tab there is a description of those tasks. Many times when they print it out they choose to omit the tab and this makes things difficult for staff who do not always work our unit. I want to force the print, but I need to still be able to select printer (as they change ofetn enough to cause issue) and also the number of copies. I thought making a button to do that and disabling other printing would force it.
 
Upvote 0
So I was able to figure out the code to complete what I was looking for. Took a few days but I think it was fairly simple.

Specific Sheet Code
Code:
Private Sub CommandButton1_Click()
On Error Resume Next
Application.EnableEvents = False
    Application.Dialogs(xlDialogPrinterSetup).Show
    Dim iCopies As String
    
        iCopies = Application.InputBox("HOW MANY COPIES?", Type:=2)
    
        If iCopies <> vbNullString Then
    ActiveWorkbook.PrintOut Copies:=iCopies
    Else
            Exit Sub
        End If
        Application.EnableEvents = True
End Sub

Workbook Code
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Cancel = True
    
    If Cancel = True Then MsgBox "PLEASE USE BUTTON ON SHEET"
    End Sub
 
Upvote 0

Forum statistics

Threads
1,214,576
Messages
6,120,350
Members
448,956
Latest member
Adamsxl

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