On Tue, 18 Mar 2008 13:21:01 -0700, Josh O.
wrote:
It gives me a "Runtime Error: 1004, Unable to Set PrintArea Property of the
PageSetup Class".
"Jim Thomlinson" wrote:
give this a try...
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
.PageSetup.PrintArea = .Range(.Range("A3"), _
.Range("PrintArea").Cells(.Range("PrintArea").Cell s.Count))
End With
End Sub
PrintArea takes a string, so just add .Address on to the end of the range.
Or you could use Excel's built in print area. When you set the print area
in the UI, it creates a name called Print_Area. Just manipulate that named
range and you won't have to access the PageSetup object at all.
With ActiveSheet
.Names.Add "Print_Area", .Range("A3:F10")
End With
or whatever range you want.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com