Print First Page VBA

Recently I answered a question regarding printing the first page of each sheet with VBA.  I had never come across this problem before but enjoyed reaching the following solution.

The following is a very simple procedure which will print the first page of each sheet in the workbook.

Option Explicit

Sub PrintFirstPage() 'Excel VBA procedure to printout first page.
Dim sh As Worksheet

For Each sh In Sheets
sh.PrintOut 1, 1, 1, , , , True, , False
Next sh

End Sub

If you wanted to print the first two sheets of each page you would change the code to the following.

sh.PrintOut 1, 2, 1, , , , True, , False

Where 2 is the character to change for the number of sheets to print out. Actually you can change the code to start or end from a different number of sheets. The first part after printout is the start number and the second part is the end number so

sh.PrintOut 5, 10, 1, , , , True, , False

means sheets 5-10 will be printed out.

The attached workbook shows how the Excel VBA procedure works on a sample data set.