PageSetup - Định dạng trang in các sheet trong workbook (1 người xem)

  • Thread starter Thread starter boyxin
  • Ngày gửi Ngày gửi

Người dùng đang xem chủ đề này

boyxin

Members actively
Tham gia
10/3/08
Bài viết
1,664
Được thích
2,335
Khi các sheet trong workbook cần định dạng trang in như nhau​
Tùy theo yêu cầu cụ thể, các bạn điều chỉnh các hông số trong code cho phù hợp nhé
PHP:
Option Explicit
Dim n As Byte
Sub PageSetup()
For n = 1 To Worksheets.Count
    With Sheets(n).PageSetup
        .PrintTitleRows = "$2:$2" 'in dong
        .PrintTitleColumns = "$B:$B" 'in cot
        .PrintArea = "$A$1:$D$100" 'Chon vung in
        .LeftHeader = "Tieu de tren - ben trai"
        .CenterHeader = "Tieu de tren - o giua"
        .RightHeader = "Tieu de tren - ben phai"
        .LeftFooter = "Tieu de duoi - ben trai"
        .CenterFooter = "Tieu de duoi - o giua"
        .RightFooter = "Tieu de duoi - ben phai"
        .LeftMargin = Application.InchesToPoints(0.25) 'Le trai
        .RightMargin = Application.InchesToPoints(0.25) 'Le phai
        .TopMargin = Application.InchesToPoints(0.25) 'Le tren
        .BottomMargin = Application.InchesToPoints(0.25) 'Le duoi
        .HeaderMargin = Application.InchesToPoints(0.25) 'Le cua tieu de tren
        .FooterMargin = Application.InchesToPoints(0.25) 'Le cua tieu de duoi
        .PrintHeadings = True 'True/False in dong, cot cua bang tinh
        .PrintGridlines = True 'True/False in dong ke khi ta khong dinh dang border
        .PrintQuality = 600 'Do phan giai may in
        .CenterHorizontally = True 'Canh giua: trai-phai
        .CenterVertically = True 'Canh giua: tren-duoi
'        .Orientation = xlPortrait 'kho giay doc
        .Orientation = xlLandscape 'kho giay ngang
        .PaperSize = xlPaperA4 'kho giay in
        .Order = xlDownThenOver 'Cach in: Tren xuong duoi, trai sang phai
'        .Order = xlOverThenDown 'Cach in: Trai sang phai, tren xuong duoi
        .Zoom = 100 'True/False Zoom trang in
'        .FitToPagesWide = 1 'dua noi dung can in ve so trang in (ngang) khi Zoom = False
'        .FitToPagesTall = 1 'dua noi dung can in ve so trang in (doc) khi Zoom = False
    End With
Next
End Sub
 
có cách nào đơn giản hơn không nhỉ! cho người mới học cũng biết chỉnh cho dể
 
Upvote 0

Bài viết mới nhất

Back
Top Bottom