Print Pages Count

spilner

Board Regular
Joined
Jun 7, 2011
Messages
146
hi,is there anyway i can know how much pages will be printed when i select a group sheets.
some of sheets i got about up to 9 pages.
thanks for your help.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi spilner,

The following will assign the number of pages to be printed to the 'intNumOfPrintPages' varaible (which I have simply displayed in a message box, but you can use it as you please):


Code:
Sub Macro2()

    Dim intNumOfPrintPages As Integer

    intNumOfPrintPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
    
    MsgBox intNumOfPrintPages

End Sub

HTH

Robert
 
Upvote 0
Ah, using this method you need to select each (visible) tab and increment the counter by the number of printouts for that tab, i.e.

Code:
Sub Macro2()

    Dim strStartTab As String, _
        strStartCell As String
    Dim intNumOfPrintPages As Integer
    
    Application.ScreenUpdating = False
    
    strStartTab = ActiveSheet.Name
    strStartCell = ActiveCell.Address
    
    For Each Worksheet In ThisWorkbook.Sheets
    
        If Worksheet.Visible = True Then
    
            With Worksheet
                .Select
                intNumOfPrintPages = intNumOfPrintPages + .Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
            End With
        
        End If
        
    Next Worksheet
    
    Sheets(strStartTab).Select
    Range(strStartCell).Select
    
    Application.ScreenUpdating = True
    
    MsgBox intNumOfPrintPages

End Sub

HTH

Robert
 
Upvote 0
i just select 3 sheets and run the macro.i dont know why it take so long to dertermine the pages.its still proccessing right now..about 1 min..
 
Upvote 0
i dont know why it take so long to dertermine the pages

Me either :confused:

It may be due to the fact the command is an old V4.0 macro which isn't as efficient as newer based macros, but it's most accurate way I've found to count the number of page(s) to be printed.
 
Upvote 0
Me either :confused:

It may be due to the fact the command is an old V4.0 macro which isn't as efficient as newer based macros, but it's most accurate way I've found to count the number of page(s) to be printed.

probably theres somethin need to fix in the code,i dont get the result tho after 10 mins wait. :(
i bet u can figure it out.
i google everything about it,i cant find good one tho.
im using excel 2010.thanks for trying man.
 
Upvote 0
See if this is any better:

Code:
Option Explicit
Sub Macro2()

    Dim blnCalcMethod As Boolean
    Dim strStartTab As String, _
        strStartCell As String
    Dim wrkTab As Worksheet
    Dim intNumOfPrintPages As Integer
    Dim objTab As Object
    
    With Application
        .ScreenUpdating = False
        If .Calculation = xlCalculationAutomatic Then
            blnCalcMethod = True
            .Calculation = xlCalculationManual
        End If
    End With
        
    strStartTab = ActiveSheet.Name
    strStartCell = ActiveCell.Address
    
    For Each wrkTab In ThisWorkbook.Sheets
    
        If wrkTab.Visible = True Then
        
            Set objTab = Sheets(wrkTab.Name)
            
            With objTab
                .Select
                intNumOfPrintPages = intNumOfPrintPages + .Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
            End With
        
        End If
        
    Next wrkTab
    
    Sheets(strStartTab).Select
    Range(strStartCell).Select
    
    With Application
        .ScreenUpdating = True
        If blnCalcMethod = True Then
            .Calculation = xlCalculationAutomatic
        End If
    End With
    
    MsgBox intNumOfPrintPages

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top