malik641
09-16-2005, 10:05 AM
I'm trying to print out a specified area on a sheet using a defined name as the range. Here is my code:
Sub Print_AF004()
Application.ScreenUpdating = False
Dim oldCell As Range
Set oldCell = ActiveCell
Range("Freezer_AF004").Select
ActiveSheet.PageSetup.PrintArea = Range("Freezer_AF004")
With ActiveSheet.PageSetup
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlPortrait
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=True, Collate:=True
ActiveSheet.PageSetup.PrintArea = ""
oldCell.Select
End Sub
I set this to an object button (rectangle shape). When I run the macro it tells me that I have only one cell selected for print.
The reason for the printpreview is to check to see of the print area was set correctly, which it is not for some reason :dunno
And BTW, the "Freezer_AF004" is the defined name (you can make it any range you want, really).
Any ideas??
Thanks
Sub Print_AF004()
Application.ScreenUpdating = False
Dim oldCell As Range
Set oldCell = ActiveCell
Range("Freezer_AF004").Select
ActiveSheet.PageSetup.PrintArea = Range("Freezer_AF004")
With ActiveSheet.PageSetup
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlPortrait
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=True, Collate:=True
ActiveSheet.PageSetup.PrintArea = ""
oldCell.Select
End Sub
I set this to an object button (rectangle shape). When I run the macro it tells me that I have only one cell selected for print.
The reason for the printpreview is to check to see of the print area was set correctly, which it is not for some reason :dunno
And BTW, the "Freezer_AF004" is the defined name (you can make it any range you want, really).
Any ideas??
Thanks