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.
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"
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.