With Tables("订单目录.订单明细")
If .Current IsNot Nothing Then
Dim pntn As String = Tables("用户自定义").Current("报表打印机")'指定打印机
Dim Book As New XLS.Book(ProjectPath & "Attachments\生产指令单.xls")
Dim fl As String = ProjectPath & "Reports\生产指令单.xls"
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Ws.PrintOut(ActivePrinter:=pntn)
App.quit '这个一定要写,退出进程里的EXCEL,否则会提示XXX已经打开
Else
MessageBox.show("没有记录!")
End If
End With
在打印机没琏接时,执行这个代码会出现错误提示!
可否帮忙给代码加个打印机是否琏接的判断?
此主题相关图片如下:捕获.png