View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Charlotte E Charlotte E is offline
external usenet poster
 
Posts: 59
Default Number of pages printed?

Works :-)

Thanks :-)



OssieMac wrote:
Don't think Leith's reply is quite accurate. Both Vertical and
Horizontal page breaks need 1 added to them.

Also need to assign the result to the function name.

Function GetWorksheetPageCount() As Integer
With ActiveSheet
GetWorksheetPageCount = (.HPageBreaks.Count + 1) _
* (.VPageBreaks.Count + 1)
End With
End Function

Function GetPageCount()
GetPageCount = Application.ExecuteExcel4Macro _
("Get.Document(50)")
End Function

Examples of using the functions:

Sub NoOfPages1()
'Call function GetWorksheetPageCount
MsgBox GetWorksheetPageCount()
End Sub

Sub NoOfPages2()
'Call function GetPageCount
MsgBox GetPageCount()
End Sub



Hello Charlotte E,

Here are 2 methods of getting the page count...

=====================================
Function GetWorksheetPageCount() As Integer
With ActiveSheet
TotalPrintPagesOnWorksheet = .HPageBreaks.Count *
(.VPageBreaks.Count + 1)
End With
End Function

Function GetPageCount()
GetPrintedPages =
Application.ExecuteExcel4Macro("Get.Document(50)")
End Function
=====================================
Sincerely,
Leith Ross


--
Leith Ross

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/)
------------------------------------------------------------------------
Leith Ross's Profile:
http://www.thecodecage.com/forumz/member.php?userid=75 View this
thread: http://www.thecodecage.com/forumz/sh...ad.php?t=87673