printing with macro


Posted by Pasi Vartiainen on October 29, 2001 12:10 AM

I have workbook which contains multiple sheet, all with different pagesetup. Since recorded macro is long, and it has unnessecary lines, here is my version. Only problem is that fit to widtg and fit to height does not work, can somebody help?

sub print_all()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
sh.Activate
If sh.Name = "Project" Then
sh.PageSetup.PrintArea = "$A$1:$I$61"
With sh.PageSetup
.Orientation = xlPortrait
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
ActiveSheet.PrintOut
End If
If sh.Name = "next_sheet" Then
...

Next
End Sub

same routine is for every sheet, some sheet has other features which are triggered by sh.name

So, why that pagesetup doesn't work? ... printarea is slighly bigger that standard A4, so I have to force it A4 size.

Hope that somebody can help me.



Posted by Leroy on October 29, 2001 12:58 AM

Pasi,

You need to set your Zoom property to False before you set your FitToPagesWide and FitToPagesTall properties.

HTH.