PDA

View Full Version : Selection Printing either Landscape or Portrait



r_know
01-27-2013, 11:19 PM
Dear All,

Please see the code below and required modifications where I should get chance to select the printing either Landscape or Portrait.
I am sure it will be useful to every excel users.


Sub PrintSelectionArea()
Dim rng As Range
'Select Range of PRINT

On Error Resume Next
Set rng = Application.InputBox("Select a Range", Type:=8)
On Error GoTo 0
If Not rng Is Nothing Then

With ActiveSheet.PageSetup

.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
' .Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With

rng.PrintOut Copies:=1, Collate:=True
End If
End Sub