Sub Pg_Set()
Dim L, R, T, B, H, F
Sheets(1).Select ' Lay gia tri le
L = Cells(7, 3)
R = Cells(9, 3)
T = Cells(11, 3)
B = Cells(13, 3)
H = Cells(15, 3)
F = Cells(17, 3)
' Dat le cho cac Sheet
For i = 1 To ActiveWorkbook.Worksheets.Count
Worksheets(i).Select
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(L)
.RightMargin = Application.InchesToPoints(R)
.TopMargin = Application.InchesToPoints(T)
.BottomMargin = Application.InchesToPoints(B)
.HeaderMargin = Application.InchesToPoints(H)
.FooterMargin = Application.InchesToPoints(F)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 300
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
Next i
Sheets(1).Select
ActiveWindow.SelectedSheets.PrintPreview
End Sub