Create a Print button [VBA]
This article describes how to create a button and place it on an Excel worksheet then assign a macro to that button allowing the user to print the worksheet when the button is press with left mouse button oned on.
Watch a video where I explain the steps to insert a print button
Create button
The button is found in the Form Controls group.
- Select sheet "Invoice".
- Press with left mouse button on "Developer tab" on the ribbon.
- Press with left mouse button on "Insert" button.
- Press with left mouse button on Button (Form Control).
- Create button "Print Invoice".
Create macro
(The macro shown in the image above is not used here in this article, it only demonstrates where to paste the code.)
- Press Alt-F11 to open the visual basic editor
- Press with left mouse button on Module on the Insert menu
- Copy and paste "Sub Macro1" code below to code module
Sub Macro1() Application.Dialogs(xlDialogPrint).Show End Sub
You can find the other invoice tutorials here: Invoice category
Form controls category
This blog post demonstrates how to create, populate and change comboboxes (form control) programmatically. Form controls are not as flexible […]
In this tutorial I am going to explain how to: Create a combo box (form control) Filter unique values and […]
This blog post shows you how to manipulate List Boxes (form controls) manually and with VBA code. The list box […]
Macro category
This article demonstrates a macro that copies values between sheets. I am using the invoice template workbook. This macro copies […]
This tutorial shows you how to list excel files in a specific folder and create adjacent checkboxes, using VBA. The […]
In this post I am going to show how to create a new sheet for each airplane using vba. The […]
Print category
Have you ever wondered how these lines got there on a worksheet? They show where pages will break, in other […]
This article demonstartes different techniques on how to take a screenshot of your worksheet. You can do that by simply […]
If you want each page to have the same row(s) or column(s) to be repeated at every page you print. […]
Excel categories
19 Responses to “Create a Print button [VBA]”
Leave a Reply
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
This is what i looking for...
after long searching, finally i found here
thnks Oscar
Dear Sir/Madam
I am very glade to see your site. It very useful for me.
But I am so sorry I can not done it form number 4 till finish.
Best regards
want to try this impressive technology,thanks alot.
Thank you for this information.
I'll try it and I need it very much.
I have a question.
If I have three or more columns A. B. C.
in each of them figures up to 50 lines.
How can I make a new column D. contains the figures of the three columns under each other.
That was good but when I try to close the excel file, a popup window says this file can't be saved and they are not related to vb.
Hi Ibraheem
maybe you saved the file previously but saved it as xls. with a macro added to the sheet you need to resave the file (file-save as-, save as type: "macro enabled worksheet")this is to save the workbook with macros attached as when you attached the print button you have also changed the file type you are working on from xls to a file with macros
i have copied the said macro "Sub Macro1()
Application.Dialogs(xlDialogPrint).Show
End Sub"
But it is not working. the message shows: "Can not run the macro. The macro may not be available in the workbook."
Pls. give me the solution.
file-save as-, save as type: "macro enabled worksheet"
I also face this problem i i get solution by this rout.
enjoy your work.
//////
Hello:
I am working with Excel 2013 trying to add a macro to print too but it's not working. Yes, I have saved it as .xlsm but there is no option to "add macro" when I right-press with mouse over the command button. I can add the macro in VBA but it's like I can't get the two to talk to each other. I'm just getting started with java scripts, macros, etc. and I am addicted! Matter of fact, I probably spend too much time trying to learn about them while at the office. Anyway, thanks for your site. Still helpful - I'll keep researching. I'm sure I'm missing something simple. :)
Hello Colleagues
I what to create Enter button that will update data to the next sheet and print the data sheet at the same time. Please help.
Hi
What shall I add in macros if I want to print more than 1 copy ?
Hi - I am using a mac and getting a "Run-time error 5941" - the requested member of the collection does not exist.
Michael Salim,
I don't have a Mac and I can't find a solution to your problem.
Can you provide the code Excel returns if you record a macro while printing a page?
it so helpful for me
thanks a lot
Oscar...
I need to insert a control that will print the active worksheet to a .pdf file.
How do I make this happen?
Thanks in advance.
God Bless...
Chuck Bradley
Sir please add new invoice button that will auto increment the invoice number
Hi,
i am looking for command to print by Buttons in sheet1 when i select Button A then this will print sheet2 and when i select Button B in sheet1 then this button will print Sheet3.
Please help me how to set this commant.
thank you for this which I was looking for
how to make calling button Find and Replace with Macro in Excel