Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1395|回复: 3

求打印工作表页面设置代码

[复制链接]
发表于 2013-6-5 14:49 | 显示全部楼层 |阅读模式
本帖最后由 没事 于 2013-6-18 07:34 编辑

求打印工作表页面设置代码:
我要打印Sheet1.[a1:h12]区域表格,要求横向,A4纸,上下左右边距为2,页脚等于Sheet1.[a1]单元格数据。这样的代码写如何,特求老师帮忙。谢谢!
发表于 2013-6-6 09:34 | 显示全部楼层
    Range("A1:H12").Select
    Range("H12").Activate
    ActiveSheet.PageSetup.PrintArea = "$A$1:$H$12"
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = "$A$1:$H$12"
    With ActiveSheet.PageSetup
        .LeftMargin = Application.InchesToPoints(0.78740157480315)
        .RightMargin = Application.InchesToPoints(0.78740157480315)
        .TopMargin = Application.InchesToPoints(0.78740157480315)
        .BottomMargin = Application.InchesToPoints(0.78740157480315)
        .HeaderMargin = Application.InchesToPoints(0)
        .FooterMargin = Application.InchesToPoints(A1)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
    End With
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
End Sub

不知道这样行不行,你试试吧!感觉自己弄得有点复杂。但我这边确实能用。呵呵
回复

使用道具 举报

发表于 2013-6-6 10:58 | 显示全部楼层
录制宏                              
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-21 10:45 , Processed in 0.655260 second(s), 7 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表