Archive for the ‘VBA Printing’ Category.

Printing Certain Pages

The PrintOut method applies to a lot of different objects. You can print a Workbook, Worksheet, Chart, Collection of Worksheets, Collection of Charts, Window object and even a Range.

PrintOut has some useful arguments including the From and To arguments. These let you define which pages will print. If, for instance, you want to print every worksheet in your workbook, but only want to print the first page, you might use a sub like this:

Sub PrintPage1()

    Dim ws As Worksheet
    
    For Each ws In ThisWorkbook.Worksheets
        ws.PrintOut From:=1, To:=1
    Next ws
    
End Sub

This will create a separate print job for every page it prints. If you want to print a lot of pages in one print job, you can use this method. You won’t be able to specify pages, though. If you tried to specify only the first page using that method, it would only print the first page of the whole print job, not the first page of every worksheet.