Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default 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
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
Reading Multiple Pages Listing Top three Results. Killer Excel Worksheet Functions 0 November 18th 06 02:36 AM
PrintArea [email protected] Excel Programming 4 July 23rd 05 12:45 AM
PrintArea rickey24[_18_] Excel Programming 1 October 7th 04 01:48 PM
PrintArea rickey24[_17_] Excel Programming 1 October 6th 04 08:04 PM
PRINTAREA Giacomo[_3_] Excel Programming 4 October 28th 03 10:43 PM


All times are GMT +1. The time now is 06:42 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"