以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 打印excel文件 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=172100) |
-- 作者:Tough -- 发布时间:2021/9/23 15:47:00 -- 打印excel文件 Dim fl As String = args(0) Dim LeftMargin As Integer = args(1) Dim RightMargin As Integer = args(2) Dim TopMargin As Integer = args(3) Dim BottomMargin As Integer = args(4) Dim Orientation As MSExcel.xlPageOrientation = args(5) Dim CenterHorizontally As Boolean = args(6) Dim CenterVertically As Boolean = args(7) Dim defultPrint As String = args(8) \'创建excel实例 Dim App As New MSExcel.Application Dim Wb As MSExcel.Workbook = App.WorkBooks.Open(fl)\'打开excel文件 Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) With Ws.PageSetup \'设置页面 .PaperSize = MSExcel.XlPaperSize.xlPaperA4 \'纸张大小 .LeftMargin = LeftMargin \'页面左边距 .RightMargin = RightMargin \'页面右边距 .TopMargin = TopMargin \'页面顶部边距 .BottomMargin = BottomMargin \'页面底部边距 .CenterHorizontally = CenterHorizontally \'页面水平居中 .CenterVertically = CenterVertically \'页面垂直居中 \'打印模式 .Orientation = Orientation \'横向打印 .PrintGridlines = True \'打印网格线 \'缩放打印 .Zoom = False\'以下设置将缩印在一页内 .FitToPagesWide = 1 \'按照1页的宽度打印 .FitToPagesTall = 1 \'按照1页的高度打印 End With Ws.PrintOut(From:=1,To:=1,Copies:=1,Preview:=False,ActivePrinter:=defultPrint)\'直接打印 App.Quit 每次打印时都弹出是否保存对文件的更改,怎么去掉这个提示,然他默认直接覆盖原文件,各位大神谁有解决的方法 |
-- 作者:有点蓝 -- 发布时间:2021/9/23 15:50:00 -- End With wb.saved = True App.DisplayAlerts = False Ws.PrintOut(From:=1,To:=1,Copies:=1,Preview:=False,ActivePrinter:=defultPrint)\'直接打印 App.Quit
|