How to Create a Print Button in Excel VBA: One-Click Printing for Faster Workflow
Contents
- How to Create a Print Button in Excel VBA: One-Click Printing for Faster Workflow
- ✅ Why You Should Create a One-Click Print Button
- ✅ Understanding the Concept: What a “Print Button” Really Does
- ✅ Step 1: Inserting a Print Button into the Sheet
- ✅ Step 2: Writing the Basic Print Macro
- ✅ Step 3: Add Confirmation Before Printing
- ✅ Step 4: Printing a Specific Range Instead of the Whole Sheet
- ✅ Step 5: Adding a Preview Option for Quality Check
- ✅ Step 6: Setting Page Layout and Margins from the Button
- ✅ Step 7: Creating a Button that Exports to PDF Instead of Paper
- ✅ Step 8: Printing Multiple Sheets from One Button
- ✅ Step 9: Assigning the Macro to a Shape (Alternative Design)
- ✅ Step 10: Creating a Floating “Quick Print” Toolbar
- ✅ Step 11: Automating the Printer Selection
- ✅ Step 12: Combining Settings into a Professional Print Macro
- ✅ Step 13: Integrating with UiPath or RPA Tools
- ✅ Step 14: Adding a Progress Message or Status Bar
- ✅ Step 15: Protecting the Button and Macro from Accidental Edits
- ✅ Step 16: Troubleshooting Common Button Print Problems
- ✅ Step 17: Real-World Business Applications
- ✅ Step 18: Enhancing Aesthetics – Design Tips for Print Buttons
- ✅ Step 19: Going Further – Adding Multiple Buttons for Different Tasks
- ✅ Step 20: Maintenance and Best Practices
- ✅ Summary: Simplify Your Workflow with a One-Click Print Button in Excel VBA
Printing reports is one of the most common tasks in Excel. Yet, many professionals still go through multiple menus — File → Print → Select printer → Confirm settings → Print — each time they need a hard copy.
When you repeat this several times a day, or across hundreds of files, it becomes frustrating and time-consuming.
By using Excel VBA, you can create a Print button that executes all these actions with a single click.
In this guide, we’ll cover not only how to create the button, but also how to customize it — controlling printer options, choosing specific sheets, and exporting to PDF automatically.
This comprehensive tutorial will help you build a professional, one-click print automation system suitable for any business environment.
✅ Why You Should Create a One-Click Print Button
Excel offers powerful print capabilities, but manual setup is inefficient. With VBA automation:
- Reports can be printed consistently, without menu navigation.
- Users with limited Excel knowledge can print safely.
- Company templates can enforce consistent layout standards.
- Combined with RPA tools like UiPath, the button can trigger fully automated workflows (print + save + email).
When you replace manual clicks with a button, productivity scales — especially in teams handling invoices, purchase orders, or daily reports.
✅ Understanding the Concept: What a “Print Button” Really Does
A print button is simply a Form Control or Shape linked to a VBA macro.
When clicked, the macro executes predefined commands like PrintOut, PrintPreview, or ExportAsFixedFormat.
・Core Commands Behind the Button
| Purpose | VBA Command | Example |
|---|---|---|
| Directly print | PrintOut | ActiveSheet.PrintOut |
| Show preview | PrintPreview | ActiveSheet.PrintPreview |
| Export to PDF | ExportAsFixedFormat | ActiveSheet.ExportAsFixedFormat xlTypePDF, "Report.pdf" |
With these three, you can automate almost any print scenario.
✅ Step 1: Inserting a Print Button into the Sheet
・Add a Form Control Button
- Go to Developer tab → Insert → Form Controls → Button.
- Draw the button on your sheet (for example near cell A1).
- In the dialog “Assign Macro,” choose New to create a VBA subroutine.
Excel automatically opens the VBA editor with a new macro like this:
Sub Button1_Click()
' Your code goes here
End Sub
This macro runs whenever the button is pressed.
✅ Step 2: Writing the Basic Print Macro
・Print the Active Sheet Instantly
Replace the comment line with this code:
Sub Button1_Click()
ActiveSheet.PrintOut
End Sub
Now, every time you click the button, the active worksheet prints immediately using default settings.
✅ Result: One-click physical printing without menus.
✅ Step 3: Add Confirmation Before Printing
Printing can be sensitive — users may click the button accidentally.
Adding a confirmation dialog avoids unwanted paper waste.
・Confirmation Example
Sub Button1_Click()
If MsgBox("Do you want to print this sheet?", vbYesNo + vbQuestion, "Confirm Print") = vbYes Then
ActiveSheet.PrintOut
End If
End Sub
✅ Now users must confirm with Yes before printing proceeds.
✅ Step 4: Printing a Specific Range Instead of the Whole Sheet
Sometimes you only need to print a portion — for instance, an invoice area or dashboard.
・Set Print Area Dynamically
Sub Button1_Click()
ActiveSheet.PageSetup.PrintArea = "$A$1:$G$40"
ActiveSheet.PrintOut
End Sub
You can also automate this by finding the used range:
Sub AutoPrintArea()
Dim rng As Range
Set rng = ActiveSheet.UsedRange
ActiveSheet.PageSetup.PrintArea = rng.Address
ActiveSheet.PrintOut
End Sub
✅ The print area automatically adjusts to fit your data.
✅ Step 5: Adding a Preview Option for Quality Check
Previewing before printing is often required in business workflows.
・Print Preview Button Macro
Sub PreviewBeforePrint()
ActiveSheet.PrintPreview
End Sub
You can assign this macro to another button labeled “Preview Before Printing”.
This ensures reports are checked visually before committing to paper.
✅ Step 6: Setting Page Layout and Margins from the Button
If different printers use inconsistent defaults, forcing page layout ensures uniform output.
・Configure Layout Automatically
Sub PrintWithLayout()
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.FitToPagesWide = 1
.FitToPagesTall = False
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
End With
ActiveSheet.PrintOut
End Sub
✅ The layout adjusts automatically, producing a professional-looking printout.
✅ Step 7: Creating a Button that Exports to PDF Instead of Paper
Digital reports are more common today. Use the same button to create PDFs automatically.
・Print to PDF Button
Sub ExportToPDF_Click()
Dim FilePath As String
FilePath = ThisWorkbook.Path & "\Report_" & Format(Now, "yyyymmdd_hhmmss") & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FilePath
MsgBox "PDF created successfully at: " & FilePath
End Sub
✅ Every click generates a timestamped PDF, perfect for record-keeping or email distribution.
Pairing this with UiPath lets an RPA robot email the file automatically to clients or managers.
✅ Step 8: Printing Multiple Sheets from One Button
A single button can trigger printing for several worksheets in sequence.
・Example Macro for Multiple Sheets
Sub PrintMultipleSheets()
Sheets(Array("Summary", "Invoice", "Details")).Select
ActiveWindow.SelectedSheets.PrintOut
Sheets("Summary").Select
End Sub
✅ Great for business forms that consist of several related sheets.
✅ Step 9: Assigning the Macro to a Shape (Alternative Design)
For a more customized look, you can use shapes instead of form buttons.
・Assign a Macro to a Shape
- Insert a shape: Insert → Shapes → Rounded Rectangle.
- Type “Print Report” inside it.
- Right-click → Assign Macro → choose your print macro.
Shapes allow branding flexibility — you can color them, add icons, or match your company’s theme.
✅ Step 10: Creating a Floating “Quick Print” Toolbar
Advanced users can insert a floating button using a userform or ActiveX control.
・Create a Floating Form with a Print Button
- Open VBA editor → Insert → UserForm.
- Add a command button.
- In the button’s click event:
Private Sub CommandButton1_Click()
ActiveSheet.PrintOut
End Sub
Show it with:
Sub ShowPrintForm()
UserForm1.Show vbModeless
End Sub
✅ The floating toolbar stays on top of Excel, giving users a quick print interface even while scrolling or editing.
✅ Step 11: Automating the Printer Selection
When your office has multiple printers, choose automatically to prevent misprints.
・Select a Specific Printer
Sub PrintToSpecificPrinter()
Application.ActivePrinter = "OfficeLaser on Ne01:"
ActiveSheet.PrintOut
End Sub
To find available printers, run:
Debug.Print Application.ActivePrinter
✅ Ensures the right report always goes to the right device.
✅ Step 12: Combining Settings into a Professional Print Macro
Below is an example of a comprehensive print macro for professional use.
Sub ProfessionalPrint()
Dim ans As VbMsgBoxResult
ans = MsgBox("Print the monthly report now?", vbYesNo + vbQuestion, "Confirm Print")
If ans = vbYes Then
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.FitToPagesWide = 1
.FitToPagesTall = False
.CenterHorizontally = True
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.CenterFooter = "Page &P of &N"
End With
ActiveSheet.PrintOut
MsgBox "Printing completed successfully!"
Else
MsgBox "Printing cancelled."
End If
End Sub
✅ Combines layout, scaling, confirmation, and footers in one streamlined macro.
✅ Step 13: Integrating with UiPath or RPA Tools
RPA (Robotic Process Automation) can extend the usefulness of your print button.
For instance:
- UiPath can run this Excel macro automatically each morning.
- The bot prints reports → exports them as PDF → attaches them to an email → and sends them to the management team.
This removes the human factor entirely while maintaining Excel’s original flexibility.
With VBA handling formatting and UiPath handling scheduling, your “print button” becomes part of a smart, enterprise-level workflow.
✅ Step 14: Adding a Progress Message or Status Bar
Long reports can take several seconds to print. Providing feedback improves user experience.
・Simple Status Notification
Sub PrintWithStatus()
Application.StatusBar = "Printing report... please wait."
DoEvents
ActiveSheet.PrintOut
Application.StatusBar = False
MsgBox "Printing finished successfully!"
End Sub
✅ Keeps users informed while Excel processes the task.
✅ Step 15: Protecting the Button and Macro from Accidental Edits
To prevent users from modifying or deleting the print button:
- Protect the sheet:
Review → Protect Sheet → Allow Using Macros but Lock Objects. - In VBA, store the code in a hidden module or a separate add-in file.
- Optional: password-protect the VBA project.
This ensures reliability in shared environments.
✅ Step 16: Troubleshooting Common Button Print Problems
| Problem | Cause | Solution |
|---|---|---|
| Button doesn’t respond | Macro not assigned properly | Re-assign the macro using right-click → Assign Macro |
| Multiple pages printed unexpectedly | No defined print area | Define .PrintArea before printing |
| Printer mismatch | Default printer changed | Specify printer explicitly in VBA |
| Macro security warning | Workbook not trusted | Enable macros or digitally sign |
| Layout distortion | Printer scaling overrides | Set .Zoom or .FitToPagesWide manually |
✅ Step 17: Real-World Business Applications
| Scenario | Benefit |
|---|---|
| Invoice printing | Employees press one button — instantly prints formatted invoice |
| Logistics & shipping | Each report printed with standardized layout and barcode |
| Finance | Consistent headers and page numbers for monthly summaries |
| HR | Employee reports exported to PDF automatically |
| Manufacturing | Print quality control sheets on specific printers via VBA |
| RPA workflows | UiPath triggers macros automatically, sending PDFs via email |
Automation improves efficiency and eliminates layout inconsistencies across departments.
✅ Step 18: Enhancing Aesthetics – Design Tips for Print Buttons
A dull gray rectangle isn’t user-friendly. Design it to look modern:
- Use rounded rectangles or icons labeled “🖨 Print Report.”
- Apply color coding: blue for preview, green for final print, red for cancel.
- Add hover effects (ActiveX controls allow this).
- Keep buttons near the top of reports for accessibility.
Professional design encourages correct usage and improves UX in shared workbooks.
✅ Step 19: Going Further – Adding Multiple Buttons for Different Tasks
You can add several buttons, each for a specific print function:
| Button Label | Macro | Function |
|---|---|---|
| “Preview” | PrintPreview | Check layout before print |
| “Quick Print” | ActiveSheet.PrintOut | Print instantly |
| “Export PDF” | ExportToPDF | Save as digital copy |
| “Batch Print” | PrintMultipleSheets | Print all selected sheets |
This modular approach helps users control how reports are generated.
✅ Step 20: Maintenance and Best Practices
- Store macros in a module named
modPrintAutomationfor clarity. - Test each printer setup before deploying across teams.
- Document macro functions in a “Help” worksheet.
- Combine VBA with workbook protection for enterprise environments.
- Regularly back up your macro-enabled file (
.xlsm).
Automation is only as good as its maintainability. Clean structure ensures long-term reliability.
✅ Summary: Simplify Your Workflow with a One-Click Print Button in Excel VBA
- A VBA print button eliminates repetitive manual steps.
- You can configure it for single sheets, specific ranges, or PDF exports.
- Page layout, margins, and printer selection can all be automated.
- Confirmation dialogs prevent accidental printing.
- Integration with RPA tools like UiPath enables full automation.
- A well-designed button improves user efficiency and professionalism.
Once mastered, the Excel VBA print button becomes more than convenience — it’s a foundation for automated reporting across entire organizations.
Your users click once, and Excel handles the rest: formatting, printing, and output — all seamlessly automated.
