Complete Guide to Printing in Excel Macros - PrintOut Method in Excel

Add to Favorites
Author:
This free Excel macro illustrates all of the possible parameters and arguments that you can include in the PrintOut Method for Excel Macros and VBA in Excel. All of the arguments are explained below as well as how to use each argument and why you might want to use each argument.

After reading this page, you will be able to create your own printing macros in Excel. One thing to note is that you only need to include the arguments which you want and they do not have to be in sequential order. For example, this means that if you don't need the "PrintToFile" argument, simply don't include it in your macro.

The PrintOut Method in Excel is how you print anything and everything from Excel within a Macro. This however, does not provide all of the formatting options that are possible in Excel. There are many other things you can do in terms of formatting for printing if you use the PageSetup features in a Macro. However, you will still have to actually print the Excel worksheet or workbook and this is why you need to PrintOut Method in Excel Macros.


PrintOut Arguments and Parameters Listed Below



From
    This argument allows you to designate the number of the page from which you would like to start printing. This allows you to more specifically narrow down the section of the Excel workbook or file which you would like to print. If you don't include this argument the printing will, by default, start with the first page of the file, simply the beginning of the file.
    • Set this argument equal to the number of the page from which you would like to start printing the Excel file.
    • Don't include this argument if you want to start printing from the very first page of the file.
To
    This argument allows you to determine the number of the last page to be printed from Excel. If you don't include this argument Excel will print everything to the last page.
    • Set this argument equal to any integer that is within or up to the number of pages to be printed in order to tell Excel up to what page you want printed.
    • Don't include this argument if you want all pages up to the last page (starting from where designated in the "From" argument if it is included) to be printed.
Copies
    This argument allows you to tell Excel how many copies of a file you would like to have printed. If you don't include this argument Excel will print one copy of the Excel file.
    • Set this to any number (integer) that corresponds with the number of copies which you would like to have printed.
    • Don't include this argument if you simply want one copy of the Excel file to be printed.
Preview
    If you want the macro to display the Print Preview window before the file is actually printed, you can use this argument. If you activate this argument, the file will not automatically print. Once the Print Preview window has been reached, the user will have to click the print button to actually make the document print. This is a good option to use if you need to verify the look and feel of the printed version of the file before it actually prints.
    • Set this argument to True to make the file appear in Print Preview mode before it is able to be printed.
    • Don't include this argument or set it to False if you want the file to automatically and immediately print.
ActivePrinter
    This is where you determine to what printer you would like to print. You can print to a regular paper printer, network printer, PDF printer, or any other printer that is already connected to the computer. The value for this argument is the actual name of the printer as it appears in the Print Dialog - to find out the name hit Ctrl + P in Excel and look to the Printer section at the very top and to the right of where it says "Name:" you will see a drop-down menu which lists all of the printers available to your computer. The exact text that appears there as the name for the printer is what you need to enter for this argument; remember that the name must go inside of quotation marks.
    • Put the name of the desired printer inside of quotation marks for this argument.
    • Don't include this argument if you want to use the default printer.
PrintToFile
    If you would like to print the Excel file to a file instead of from a printer onto paper, you can use this argument. This is most often used when converting an Excel file into a PDF file because you have to 'print' to the PDF file.
    • Set this argument to True if you want to print to a file.
    • Don't include this argument or set it to False if you want to print the Excel file to paper.
Collate
    This option allows you to determine whether or not you would like the printed copies of the workbook or worksheet to be collated. This argument is irrelevant if you are only printing one copy.
    COLLATE: This means that if you have a five page document, which you want to print 2 times, and you choose to collate the document, it will print in this order: 12345 12345. If you choose not to collate the document will print in this order: 11 22 33 44 55.
    • Set this to True to collate copies of the printed Excel file.
    • Set this to False in order not to collate multiple copies of the Excel file.
PrToFileName
    If PrintToFile is set to True, this will specify the name to which you would like to save the file. Depending on the type of file you are printing and the software used, this may or may not actually set the saved file to the name defined here.
    • Make sure to enclose the name in quotes or leave this argument blank or with empty quotes (i.e. quotes with nothing in between.
IgnorePrintAreas
    This determines whether or not to respect prescribed print areas within the worksheet or to simply print the entire worksheet or workbook and not just the selected print areas.
    • Set this to True to ignore print areas in Excel.
    • Don't include the argument or set it to False to respect print areas in Excel.

Where to install the macro:  Module

Macro to Print in Excel - Complete PrintOut Method with All Arguments Listed

Sub PrintOut_Method_All_Parameters_Listed()
'List of all of the optional parameters for printing an Excel spreadsheet using the PrintOut method

Worksheets.PrintOut _
From:=1, _
To:=10, _
Copies:=1, _
Preview:=False, _
ActivePrinter:="", _
PrintToFile:=False, _
Collate:=True, _
PrToFileName:="", _
IgnorePrintAreas:=False

End Sub







Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons 50+ Hours of Instruction 200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course



How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.

Tutorial Details
Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course