View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
J.E. McGimpsey J.E. McGimpsey is offline
external usenet poster
 
Posts: 493
Default Excel Page count

One way:

Public Function NumPagesInWorkbook( _
Optional ByRef wkBook As Workbook) As Integer
Dim wkSht As Worksheet
If wkBook Is Nothing Then Set wkBook = ActiveWorkbook
For Each wkSht In wkBook.Worksheets
With wkSht
If Application.CountA(.Cells) Then
NumPages = NumPages + _
(.HPageBreaks.Count + 1) * _
(.VPageBreaks.Count + 1)
End If
End With
Next wkSht
End Function

In article ,
"Joe" wrote:

Would anybody have some example code that shows count the
number of pages that are shown in the page break preview
in Excel? I am trying to get page counts from different
office files by looping thru a column in Excel that
contains file names. When I find an Excel file, I want to
count the number of pages that will be displayed in the
page break preview view.


Thanks

Joe.