Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Print Ranges when Print_Area not set

How do you determine in VBA the range that will be printed
on a worksheet when the print area for that sheet has not
been set?

I would expect some kind of PrintRange property of the
worksheet.pagesetup object but I have not been able to
find anything like this. (I remember something similar in
the old Excel Macro language?)

As the application places a dotted line around the Print
range (after the first preview) I would expect that this
range would be available.

In a multiple page worksheet I can determine the ranges of
all but the last page using the HPageBreaks and
VPageBreaks property of the worksheet object. However, I
cannot determine the range of the last page.

Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Print Ranges when Print_Area not set

Hi,

If no print area is set, the Printarea is empty, but Excel
then by default prints everthing between cell A1 and the
last cell that is in use. So:

Sub test()
Dim sArea As String
sArea = ActiveSheet.PageSetup.PrintArea
If sArea = "" Then
With ActiveSheet
sArea = .Range("a1", .Cells.SpecialCells
(xlLastCell).Address).Address
End With
End If
MsgBox sArea
End Sub


Regards,

Jan Karel Pieterse
Excel TA/MVP

-----Original Message-----
How do you determine in VBA the range that will be

printed
on a worksheet when the print area for that sheet has not
been set?

I would expect some kind of PrintRange property of the
worksheet.pagesetup object but I have not been able to
find anything like this. (I remember something similar in
the old Excel Macro language?)

As the application places a dotted line around the Print
range (after the first preview) I would expect that this
range would be available.

In a multiple page worksheet I can determine the ranges

of
all but the last page using the HPageBreaks and
VPageBreaks property of the worksheet object. However, I
cannot determine the range of the last page.

Any ideas?
.

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
How to print noncontiguous ranges? [email protected] Excel Discussion (Misc queries) 1 March 6th 07 11:47 PM
Print Area ranges print on separate pages? Lyndon Excel Discussion (Misc queries) 1 December 29th 06 05:22 PM
Excel: Blank Screen Stuck in Wierd Print_Area mode Shell E Excel Discussion (Misc queries) 1 December 8th 06 04:07 PM
Variable Print Ranges Zshepherd Excel Discussion (Misc queries) 0 December 2nd 04 03:23 PM
Print Ranges Alan Excel Programming 3 August 31st 03 10:47 AM


All times are GMT +1. The time now is 12:01 AM.

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

About Us

"It's about Microsoft Excel"