以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 打印格式设置 加了两行后 出现异常来自 HRESULT:0x800A03EC (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=180040) |
-- 作者:873773115 -- 发布时间:2022/9/24 15:02:00 -- 打印格式设置 加了两行后 出现异常来自 HRESULT:0x800A03EC With Ws.PageSetup .PrintArea = "A" & FirstRow - 4 & ":j" & Endrow1 \'打印工作表的指定区域 .PaperSize = MSExcel.XlPaperSize.xlPaperStatement .LeftMargin = 1 \'页面左边距 .RightMargin = 1 \'页面右边距 .TopMargin = 1 \'页面顶部边距 .BottomMargin = 1 \'页面底部边距 .CenterHorizontally = True \'页面水平居中 .CenterVertically = True \'页面垂直居中 .Orientation = MSExcel.xlPageOrientation.xlLandscape End With App.Visible = True Ws.PrintPreview \'\' ws.PrintOut wb.close(False) App.Quit
|
-- 作者:873773115 -- 发布时间:2022/9/24 15:19:00 -- 好像win7就能正常运行,win10不行 麻烦老师看看 |
-- 作者:有点蓝 -- 发布时间:2022/9/24 15:40:00 -- 我电脑是win10,测试没有问题。做个例子发上来测试一下 Dim App As New MSExcel.Application Try Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\\问题\\格式1.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) With Ws.PageSetup .PrintArea = "A1:B4" \'打印工作表的指定区域 .PaperSize = MSExcel.XlPaperSize.xlPaperStatement .LeftMargin = 1 \'页面左边距 .RightMargin = 1 \'页面右边距 .TopMargin = 1 \'页面顶部边距 .BottomMargin = 1 \'页面底部边距 .CenterHorizontally = True \'页面水平居中 .CenterVertically = True \'页面垂直居中 .Orientation = MSExcel.xlPageOrientation.xlLandscape End With App.Visible = True Ws.PrintPreview wb.close(False) App.Quit Catch ex As Exception App.Quit End Try |