Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading the PrintArea Pages
Before I start on VBA code to do this, I figured I'd ask if anyone has
already has code to do something close or suggestions on how to approach it. The functions I'm looking for a 1. NumberOfPrintPages (returns the number of pages setup for printing) Will this equation do it? ((activesheet.hpagebreaks.count+1) * (activesheet.vpagebreaks.count+1)) 2. PrintPageAreas (returns an array containing the Range (or address) of each print page This one is a bit more complex. I need to know the range of each page area. Thanks, - Pat |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading the PrintArea Pages
1. You must be sure that PageBreaks have been turned on first, so I would
write your function like the following: Public Function NumberOfPrintPages(ws As Worksheet) As Long With ws .DisplayPageBreaks = True NumberOfPrintPages = (.HPageBreaks.Count + 1) _ * (.VPageBreaks.Count + 1) End With End Function then call it like so: Public Sub Test() Dim lngPages As Long lngPages = NumberOfPrintPages(ActiveSheet) End Sub 2. For the range of cells that occupy each printed page, you will have to iterate through the HPageBreaks and VPageBreaks collections, then get the Location property of each object that is returned. I don't have code for this. -- Regards, Bill Renaud |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading the PrintArea Pages
Hello Pat,
To determine the number of pages that will print out, check out this page: http://www.j-walk.com/ss/excel/tips/tip65.htm Hope this helps, JP On Oct 5, 2:17 pm, Dreiding wrote: Before I start on VBA code to do this, I figured I'd ask if anyone has already has code to do something close or suggestions on how to approach it. The functions I'm looking for a 1. NumberOfPrintPages (returns the number of pages setup for printing) Will this equation do it? ((activesheet.hpagebreaks.count+1) * (activesheet.vpagebreaks.count+1)) 2. PrintPageAreas (returns an array containing the Range (or address) of each print page This one is a bit more complex. I need to know the range of each page area. Thanks, - Pat |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading the PrintArea Pages
Thanks JP.
Amazing, the Excel4 command does exactly what I'm looking for in the page count. It tells me the number of pages within my print area. The equation I showed isn't limited to the print area. Is there anyplace I can find the definitions of them? Regards, - Pat |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading the PrintArea Pages
Pat wrote:
<<Is there any place I can find the definitions of them? ActiveSheet.PageSetup.PrintArea .... will return a string that represents the print area on the active sheet (i.e. "$A$1:$P$27"). You would then have to write a routine to count how many page breaks are inside this area (subset of the whole page), if you want to know how many printed pages the print area would be. -- Regards, Bill Renaud |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Reading Multiple Pages Listing Top three Results. | Excel Worksheet Functions | |||
PrintArea | Excel Programming | |||
PrintArea | Excel Programming | |||
PrintArea | Excel Programming | |||
PRINTAREA | Excel Programming |