since adding an answer and getting paid for it seems to be a
horrendous amount of work, and since i only found that out after
writing the answer to your question, you get an answer for free. I
guess I'll have your eternal gratitude. I'm not sure if you can
withdraw your question or if you are bound to pay unless no one
answers. Either way:
Open a new workbook.
Open visual basic editor -> ALT + F11
Select new workbook from list in the project browser (top left window
pane, if you cannot see it, CTRL + R should summon it, the project
browser that is)
From menu bar: Insert -> Module
then, copy and paste the following code (without the stars)
**********************
Sub Format_For_Print()
'note that Excel cannot scale to less than 10% or more than 400%
making it impossible to fit
'documents with many, many rows or many many columns on 1 page
Dim sh_Sheet As Worksheet
Dim i As Integer
For Each sh_Sheet In Application.ActiveWorkbook.Worksheets
sh_Sheet.Activate
If TypeName(sh_Sheet) <> "Chart" Then
ActiveWindow.View = xlPageBreakPreview
'determine whether portrait or landscape depending on
height:width ratio
With ActiveSheet.PageSetup
Select Case ActiveSheet.UsedRange.Height /
ActiveSheet.UsedRange.Width
Case Is >= 1
For i = 1 To 2
.Orientation = xlPortrait
.Zoom = False
.FitToPagesWide = False
.FitToPagesTall = 1
Next
Case Is < 1
For i = 1 To 2
.Orientation = xlLandscape
.Zoom = False
.FitToPagesTall = False
.FitToPagesWide = 1
Next
End Select
End With
End If
Next
End Sub
*****************
you should then be able to run the macro as you would any other macro.
be sure to have the workbook you inserted the module in open, and the
workbook you want formatted selected (otherwise you are going to
format whatever happens to be the active workbook).
Cheers,
Sadao |