Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Number of pages printed?

Hello,


When I press 'Preview Print' it says, at the buttom, how many pages the
spreadsheet will use upon being printed, i.e.: "Page 1 of 4".

Is it possible to optain this number (4) in VBA and assign it to a variable?


TIA,



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Number of pages printed?


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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Number of pages printed?

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

--
Regards,

OssieMac


"Leith Ross" wrote:


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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Number of pages printed?

I believe that one must first preview a worksheet before one can return the
print page count. It may be possible to get the count to work by changing
to page break preview first. Try the sample codes immediately after opening
Excel and before printing or do a preview to see if they work.

Robert Flanagan
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"Charlotte E" <@ wrote in message
...
Hello,


When I press 'Preview Print' it says, at the buttom, how many pages the
spreadsheet will use upon being printed, i.e.: "Page 1 of 4".

Is it possible to optain this number (4) in VBA and assign it to a
variable?


TIA,





  #5   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
number of pages will be printed Jon Excel Discussion (Misc queries) 0 November 17th 08 09:24 AM
Increment Date Based on Number of Pages Printed [email protected] Excel Discussion (Misc queries) 2 May 10th 06 07:03 PM
Excel 2003 - Determine the number of printed pages SMORGS Excel Programming 0 December 5th 05 10:56 PM
Get number of pages to be printed - before print Les Stout[_2_] Excel Programming 8 October 27th 05 05:17 PM


All times are GMT +1. The time now is 11:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"