Dim i As Integer = 0
Dim bclj As String = SpecialFolder.DesktopDirectory & "\打印文件"
For Each File As String In FileSys.GetFiles(bclj)
Dim k As String = FileSys.GetName(File)
Dim Values() As String = k.split("&")
Dim m As String = Values(0)
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(File)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
With Ws.PageSetup
.PaperSize = MSExcel.XlPaperSize.xlPaperA4 '纸张大小
.RightHeader = m
'打印模式
.Orientation = MSExcel.xlPageOrientation.xlPortrait '纵向打印
'缩放打印
.Zoom = False'以下设置将缩印在一页内
.FitToPagesWide = 1 '按照1页的宽度打印
.FitToPagesTall = 1 '按照1页的高度打印
End With
App.Visible = True
Ws.PrintOut
App.Quit '这里退出会弹窗提示是否保存
Sendkeys.Send("{^}N") '我想模拟点击“否” 但没反应
Next
Output.Show("操作完成")
问题:我想打印后 自动关闭 并且不保存 上面的模拟按键没反应,或者 MSExcel.WorkBook 如果退出不保存呢?
[此贴子已经被作者于2024/5/10 14:10:42编辑过]
以下是引用有点蓝在2024/5/10 10:26:00的发言:
……
End With
wb.Saved = True App.Visible = True
Ws.PrintOut
App.Quit
wb.Saved = True 这是保存吧?我是需要 不保存
[此贴子已经被作者于2024/5/10 11:09:46编辑过]