-
Solved: Print Preview
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.
[vba]
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
[/vba]
[vba]
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
[/vba]
[VBA]
Sub PrintPreview()
'Preview Sheet
' ActiveWindow.SelectedSheets.PrintPreview
' ActiveWindow.PrintPreview
ActiveSheet.PrintPreview
End Sub
[/VBA]
Thanks
Gary
-
A gift to me from Anne originally. HTH. Dave
[vba]
With Sheets("Both Platoons")
LastRow = .Cells(.Cells.Rows.Count, "A").End(xlUp).Row()
End With
[/vba]ps. I think this should also work...
[vba]
LastRow = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row()
[/vba]
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?
Last edited by Dave; 06-01-2009 at 10:35 PM.
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules