Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Relative Reference Print Area Glitch

Status
Not open for further replies.

dls999

Technical User
Dec 4, 2002
3
US
Note: I use Excel XP, with Windows 2000, and Excel XP VBA -
If I print a range of cells manually, or with VBA code using absoulte referencing, I can print the entire range without issue, even if there is data (letters, symbols, numbers or even a single space) in the TOP MOST LEFT HAND CELL of the range (in this example cell "A9"), However, I have the following code:

Sub test_print3()
'Print a range of cells using Relative References.

'Determine Top Row
TR = 9 ' TR = Top Row
'Determine Bottom Row
BR = 59 'BR = Bottom Row

'Set top and Bottom of Range
RT = "A" & TR 'Row Top
RB = "L" & BR 'Row Bottom
Range([RT], [RB]).Select 'this will be the Print Range

'Print Range
ActiveSheet.PageSetup.PrintArea = Range([RT], [RB])

'Print Range
Selection.PrintOut Copies:=1, Collate:=True

End Sub

I get an error at the
"ActiveSHeet.PageSetup.PrintArea = Range..." line.
It pops up the following message:
"Run-Time Error '1004':
Unable to set the PrintArea property of the PageSetup Class"

If I remove all data from the TOP Most LEFT HAND Cell , (no spaces or anything) it works, but if there is any data in it, it will not work.

Any ideas? is this a known MS XP VBA glitch?

Thanks
Dan S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top