Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Set print Range

Hi,

I'm trying to set the print range of a report. The code I'm using is a
follows

Dim Print_Range As Range
Print_Range = Range("A1:E1", Selection.End(xlDown)).Select
ActiveSheet.PageSetup.PrintArea = Print_Range
End Sub

This isn't working though with a Run-time error 91, Object Variable or With
block variable not set.

Any ideas

Paul


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Set print Range

Paul

When you assign a range, you have to use the Set keyword and don't use the
Select method

Set Print_Range = Range("A1:E1", etc...

The PrintArea property of the PageSetup object takes a string, not a range,
so that would look like

ActiveSheet.PageSetup.PrintArea = Print_Range.Address

See here

http://www.dicks-blog.com/excel/2004...g_the_pri.html

I would do it like this

Dim Print_Range As Range

With ActiveSheet
Set Print_Range = .Range("A1", .Range("A1").End(xlDown).Offset(0,4))
.PageSetup.PrintArea = Print_Range.Address
End With

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"PC" <paulm DOT c at iol DOT ie wrote in message
...
Hi,

I'm trying to set the print range of a report. The code I'm using is a
follows

Dim Print_Range As Range
Print_Range = Range("A1:E1", Selection.End(xlDown)).Select
ActiveSheet.PageSetup.PrintArea = Print_Range
End Sub

This isn't working though with a Run-time error 91, Object Variable or

With
block variable not set.

Any ideas

Paul




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Set print Range

Thanks Dick, Much appreciated

"Dick Kusleika" wrote in message
...
Paul

When you assign a range, you have to use the Set keyword and don't use the
Select method

Set Print_Range = Range("A1:E1", etc...

The PrintArea property of the PageSetup object takes a string, not a

range,
so that would look like

ActiveSheet.PageSetup.PrintArea = Print_Range.Address

See here

http://www.dicks-blog.com/excel/2004...g_the_pri.html

I would do it like this

Dim Print_Range As Range

With ActiveSheet
Set Print_Range = .Range("A1", .Range("A1").End(xlDown).Offset(0,4))
.PageSetup.PrintArea = Print_Range.Address
End With

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"PC" <paulm DOT c at iol DOT ie wrote in message
...
Hi,

I'm trying to set the print range of a report. The code I'm using is a
follows

Dim Print_Range As Range
Print_Range = Range("A1:E1", Selection.End(xlDown)).Select
ActiveSheet.PageSetup.PrintArea = Print_Range
End Sub

This isn't working though with a Run-time error 91, Object Variable or

With
block variable not set.

Any ideas

Paul






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
print range won't print Cheri K Excel Discussion (Misc queries) 2 February 25th 10 11:49 PM
Print range Lawman Setting up and Configuration of Excel 3 July 8th 08 01:50 PM
Print Blank Pgs - Preview margins outside print range dsm Excel Discussion (Misc queries) 0 October 25th 06 06:17 PM
Excel 2000 VBA - Set Print Range in dynamic range sub_pop[_5_] Excel Programming 2 July 27th 04 08:01 PM
Print Range jacqui[_2_] Excel Programming 0 July 23rd 03 04:19 PM


All times are GMT +1. The time now is 12:38 PM.

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"