Excel 请教设置打印区域的代码怎么写
参考一下:Sub pripage() '打印设置'Application。Dialogs(xlDialogPrinterSetup)。Show '一句话代码,调出系统对话框手动设置选择打印区域'----------------------------------------------With ActiveSheet。 PageSetup '按自定义纸张打印 '注意:需先在打印设置中自定义一个命名为“SHD”的页面尺寸(长21cm*宽14。7cm) 。PaperSize = xlPaperSHD '设置纸张的大小为自定义的“SHD”。 若...全部
参考一下:Sub pripage() '打印设置'Application。Dialogs(xlDialogPrinterSetup)。Show '一句话代码,调出系统对话框手动设置选择打印区域'----------------------------------------------With ActiveSheet。
PageSetup '按自定义纸张打印 '注意:需先在打印设置中自定义一个命名为“SHD”的页面尺寸(长21cm*宽14。7cm) 。PaperSize = xlPaperSHD '设置纸张的大小为自定义的“SHD”。
若为xlPaperA4则为A4纸 。Orientation = xlPortrait '该属性返回或设置页面的方向。wpsOrientPortrait 纵向;wpsOrientLandscape 横向 。
LeftMargin = Application。InchesToPoints(1。5) 。RightMargin = Application。InchesToPoints(1。
5) 。TopMargin = Application。InchesToPoints(1。5) 。BottomMargin = Application。InchesToPoints(1。
5) 。HeaderMargin = Application。InchesToPoints(1) 。FooterMargin = Application。InchesToPoints(1) 。
PrintGridlines = True 。CenterHorizontally = True '页面的水平居中 '。CenterVertically = True '页面垂直居中 。
Zoom = False '将页面缩印在一页内 。FitToPagesWide = 1 'If Range("A1") <> "" Then ‘设置触发找印条件 。
PrintArea = "" '取消打印区域 '。PrintArea = "$A$3:$G$18" 'Range("A3:G18")。PrintOut Copies:=1, Collate:=True '打印指定区域,直接打印 Range("A3:G18")。
PrintOut Copies:=1, Preview:=True, Collate:=True '打印预览。 'End If '上面代码即[a3:G18]。PrintOutEnd Sub。
收起