Udemy logo

vba printVisual Basic for Application, which is commonly referred to as VBA, is one of the easiest programming languages to pick up on. Created by Microsoft, this programming language has various uses and applications, as the name suggests. Through the program, you can create various objects and classes, and even print out documents. VBA Print is just one of the commands you can use, and you can diversify it greatly to change the way you print out documents in your computer.

We will assume that you already know how to use VBA and Excel, but if you don’t you can check out the course Microsoft Excel – VBA. For those who are completely new to both Visual Basic for Applications and programming in general, try the Visual Basic for Excel Tutorial course. With over 60 discussions being held in the course and more than 8 hours of content, you can easily get into VBA programming.

VBA Macros

Of all the various features you can find in VBA, macros are one of the most useful for your work. VBA Macros are bits of compacted pieces of code that are created to be used in VBA. The main reason that macros exist is to reduce the amount of work a programmer has to do when they are writing their own code. It can save time, money, and if you know anything about programming, you know that it can save you from a great deal of headaches as well.

VBA Print has limitations on VBA when you first start out, but if you are willing to install a few macros, you can actually make the task easier. There are some macros you can use that turn the process of printing into inputting a basic command or function.

This Udemy blog Excel VBA Functions is a great post that can help you out even more when it comes to understanding and creating macros. It may not teach you everything, but it will definitely help you when it comes to understanding the basics and why they’re so important in Excel VBA.

Installing macros is easy, and using them is as simple as doing any other type of programming. If you aren’t sure about how to install macros, and you want to try adding a few to your own VBA program to make things easier on you then take this Udemy course about VBA macros.

How to Perform VBA Print for Excel

Setting Up Your Button to Print

Now that you’ve created your print button, you have to write a few basic lines of code to get it to operate. First you name your Macro into the Macro Name field, name it anything you want, but make sure that it stays relevant so you don’t get confused later. Click the new button and your VBA editor window will appear.

The VBA editor window is where you will actually see the code you will be editing and rearranging in order to get the button to perform specific tasks.

Place your cursor between two lines of code, “Sub PrintCurrentSheet ()” and “End Sub”. After you do that you will write the following line of code yourself:


Now all you have to do is right-click the command button and highlight the Button 1 text. Change it to something, such as “Quick Print”, and that is all there is to it. You have a button that prints instantly using VBA.

Tips and Using Other Print Function 

In the tutorial above we only showed you one of the ways to print out documents, but you can change it to be more customizable if you want. For example, if you want to make it so that your button doesn’t print to the default printer that’s connected to your computer, but instead you choose the printer then you just have to write the following code in the same place where you wrote the previous line of code.

Sub QuickChangePrinter()
Dim sNewPrinter As String
sNewPrinter = ActivePrinter
ActivePrinter = "Enter the  name of the printer here"
Application.PrintOut FileName:=""
ActivePrinter = sNewPrinter
End Sub

This tells Excel to prompt you before printing begins so you can choose the printer where you want your documents to be made.

Important Pieces of Code to Remember

When you’re using VBA Print, you want to remember some key aspects of code that you will be seeing regularly.

Using VBA Print for Business

Businesses all around the world use VBA Excel to help them create content and navigate quickly through Microsoft Excel and various documents. For any business professional, this tool can be easy to learn and utilize.

VBA print specifically though is a great resource, especially for those companies that handle several hundred or even thousand documents a day. Through VBA print and other forms of VBA, you could easily deal with these documents and cut out a great deal of time from your work.

The Udemy course Ultimate Excel VBA teaches business professionals about some of the key aspects of programming they will need in order to make their jobs a lot easier. The course has over 8 hours of instruction all designed to teach you how to use programming to make writing in Excel faster and more efficient.

Page Last Updated: February 2020

Excel VBA students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy Business.

Request a demo