VBA之EXCEL打印

活动工作表打印

Sub Print()

       ActiveSheet.PrintOut

End Sub

 

设置页面

Sub PrintSh()

       With WorkSheets(“Sheet1”)

       ‘设置打印方向

              .PageSetup.Orienttation=xlLandscape

       End With

End Sub

 

设置第一张工作表的所有页边距

Sub SetPage()

       With Worksheets(1).PageSetup

              .LeftMargin=Application.InchesToPoints(0.5)

              .RightMargin=Application.InchesToPoints(0.75)

              .TopMargin= Application.InchesToPoints(1.5)

.BottomMargin= Application.InchesToPoints(1)

.HeaderMargin= Application.InchesToPoints(0.5)

.FooterMargin= Application.InchesToPoints(0.5)

       End With

End Sub

 

页眉折行打印

Sub Printer()

       ActiveSheet.PageSetup.CenterHeader=”&””Arial,Bold Italic””&14 期末成绩表” _

              & Chr(13) & Sheets(2).Range(“A1”)

       ‘打印预览

       ActiveWindow.SelectedSheets.PrintPreview

ActiveWindow.SelectedSheets.PrintOut Copies:=1   ‘打印一份文件

End Sub

 

为工作簿中每个工作表进行设置,设置打印为1-3

Sub Top3LinesPrint()

       Dim wkSheet as WorkSheet

       For Each wkSheet In Application.Worksheets

              With wkSheet.PageSetup

                     .PrintTitleRows=”$1:$3”

              End With

              Sheets(wkSheet.Name).Rows(“1:3”).Font.Bold=True

       Next wkSheet

End Sub

 

设置工作表标签颜色

ActiveSheet.Tab.ColorIndex=6

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值