我电脑是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