代码没问题的。你掉出任务管理器,把所有的excel进程都结束后,再测试下面代码
Dim pnt As WinForm.ComboBox = e.Form.Controls("printer")'取得打印机名称
Dim pntn As String = pnt.Text
SaveConfigValue("pntname1",pntn)
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
try
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Ws.PrintOut(ActivePrinter:=pntn)
catch ex As exception
msgbox(ex.message)
finally
App.quit
End try