|
本帖最后由 dyzx 于 2016-12-21 16:31 编辑
各位老师:请问怎样统一设置页面格式(将7班、8班....等N个班统一设置打印页面格式,代码怎样写,请指教,多谢。
- Sub 页面设置3()
- 'tt = Timer
- Dim sh As Worksheet
- Application.PrintCommunication = False
- For Each sh In Worksheets
- If sh.Name Like "*班" Then x = x & "," & sh.Name
- Next
- x = Mid(x, 2)
- If InStr(x, ",") > 0 Then Sheets(Split(x, ",")).Select Else If Len(x) > 0 Then Sheets(x).Select
- Sheets(Split(x, ",")(0)).Activate
- With ActiveSheet.PageSetup
- .Orientation = xlLandscape '纸张横向'
- .Orientation = xlPortrait '纸张纵向'
- .PaperSize = xlPaperA4
- .LeftMargin = Application.CentimetersToPoints(0.1)
- .RightMargin = Application.CentimetersToPoints(0.1)
- .TopMargin = Application.CentimetersToPoints(1)
- .BottomMargin = Application.CentimetersToPoints(1)
- .HeaderMargin = Application.CentimetersToPoints(1)
- .FooterMargin = Application.CentimetersToPoints(0.5)
- .BlackAndWhite = True '单色打印
- .PrintTitleRows = "$1:$2" '设置“顶端标题行”
- .CenterHorizontally = True '水平居中
- .LeftFooter = "第 &P 页,共 &N 页"
- End With
- Application.PrintCommunication = True
- 'MsgBox Timer - tt
- End Sub
复制代码
|
|