PDA

View Full Version : Solved: Print Preview



zoom38
06-01-2009, 06:17 PM
Hello all,
Is there a way to print preview a hidden sheet? My code below works if I set the sheet to visible but doesn't work if the sheet remains hidden.


Sub PrintBothPlatoonsMain()

Dim ThisSheet As Worksheet
Set ThisSheet = ActiveSheet

Application.ScreenUpdating = False
Application.EnableEvents = False

Module1.DoProtect False
Sheets("Both Platoons").Visible = True
Call BothPlatoonsSheet
Call PrintSetupForBothPlatoons
Call PrintPreview
Sheets("Both Platoons").Visible = False
'Call PrintCopies
Module1.DoProtect True

ThisSheet.Activate
Application.ScreenUpdating = True
Application.EnableEvents = True


End Sub



Sub PrintSetupForBothPlatoons()
Dim LastRow As Long
Sheets("Both Platoons").Activate
'Find The Last Row On The Worksheet
LastRow = Cells(Rows.Count, 1).End(xlUp).Row

With ActiveSheet.PageSetup
.Orientation = xlLandscape
.CenterVertically = True
.LeftMargin = Application.InchesToPoints(1.06)
.RightMargin = Application.InchesToPoints(0)
.PaperSize = xlPaperLegal
.PrintArea = "$A$1:$AF" & LastRow
.Zoom = 93
'.Zoom = False
'.FitToPagesWide = 1
End With
End Sub



Sub PrintPreview()
'Preview Sheet
' ActiveWindow.SelectedSheets.PrintPreview
' ActiveWindow.PrintPreview
ActiveSheet.PrintPreview
End Sub



Thanks
Gary

Dave
06-01-2009, 10:21 PM
A gift to me from Anne originally. HTH. Dave

With Sheets("Both Platoons")
LastRow = .Cells(.Cells.Rows.Count, "A").End(xlUp).Row()
End With
ps. I think this should also work...

LastRow = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row()


On edit I see that this isn't actually your area of difficulty... but your syntax does look off. Anyways, I'll leave this post and thread bump to hopefully get you some help. Where's this sub "BothPlatoonsSheet" anyways?

zoom38
06-02-2009, 05:22 AM
Well I found several references to printing hidden sheets on the net and they all say you have to unhide the sheet before printing.
By the way Dave, I am not experiencing any problems with the lastrow line I just wanted to print preview a hidden sheet without unhiding it.


Thanks anyway
Gary