以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  指定打印机出现错误  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=99213)

--  作者:xietan417
--  发布时间:2017/4/14 15:37:00
--  指定打印机出现错误
.NET Framework 版本:2.0.50727.3655
Foxtable 版本:2017.3.18.1
错误所在事件:窗口,电汇凭证,Button2,Click
详细错误信息:
服务器出现意外情况。 (异常来自 HRESULT:0x80010105 (RPC_E_SERVERFAULT))


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
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Ws.PrintOut(ActivePrinter:=pntn)
App.quit 


--  作者:有点色
--  发布时间:2017/4/14 16:00:00
--  

 代码没问题的。你掉出任务管理器,把所有的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