Sub Macro2()
Dim intNumOfPrintPages As Integer
intNumOfPrintPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
MsgBox intNumOfPrintPages
End Sub
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
i dont know why it take so long to dertermine the pages
Me either
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.
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