macro for printing? problems


Posted by Pasi Vartiainen on September 04, 2001 2:38 AM

I have macro whisch does pagesetup for each sheet in my workbook, and does sets printarea and printing option for each sheet. macro is long, so here is a sample.
----

Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.Name = "Sheet1" Then
sh.PageSetup.PrintArea = "$A$1:$I$61"
Call muotoile(xlPortrait, 1, 1)
End If
...
...
...
If sh.Name = "Sheet10" Then
sh.PageSetup.PrintArea = "$A$1:$BA$43"
Call muotoile(xlLandscape, 1, False)
End If
next
...
Function muotoile(suunta, leveys, korkeus)
With ActiveSheet.PageSetup
.Orientation = suunta
.PaperSize = xlPaperA4
.FitToPagesWide = leveys
.FitToPagesTall = korkeus
End With
End Function
----

Function muotoile is called for each individual sheet, sheets are identified by their name, and function is given three parametres; orientation, and fitting to height and width. But the setup doesn't work, what is wrong? All sheets come out in landscape? Can somebody help?

- pasi -



Posted by Ivan F Moala on September 08, 2001 12:35 AM

Try activating the sheet before setting print area via function