OzGrid

Excel VBA: Determine Number of Pages to be Printed

< Back to Search results

 Category: [Excel]  Demo Available 

Excel VBA: Determine Number of Pages to be Printed

 

Got any Excel/VBA Questions? Free Excel Help

In Excel we can use Excel VBA code to determine the number of pages that will be printed from the active sheet. There are actually 2 ways, with the first being an old Excel4 Macro.

Sub PrintedPages()

    MsgBox ExecuteExcel4Macro("Get.Document(50)")

End Sub

Or, the VBA code would be like:

Sub HowManyPagesBreaks()







    Dim iHpBreaks As Integer, iVBreaks As Integer

    Dim iTotPages As Integer

    

    iHpBreaks = ActiveSheet.HPageBreaks.Count + 1

    iVBreaks = ActiveSheet.VPageBreaks.Count + 1

    

    iTotPages = iHpBreaks * iVBreaks

    MsgBox "This sheet will require " & iTotPages & _

    " page(s) to print", vbInformation, "OzGrid.com"

End Sub
 

See also:

Prevent Save As in Excel
Prevent Excel Being Saved With Another Name
Prevent Save Prompts in Excel
Excel VBA: Determine Number of Pages to be Printed

 

See also Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions.

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)