最近在使用PB9按OLEOBJECT调用WORD过程中,对出现类似如下的
“Error calling external object function senddata at line。。。”错误,需要程序能捕获到,下面是代码段:
//连接word integer li_ret li_ret = ole_object.ConnectToObject("Word.application") if li_ret <> 0 then //如果Word还没有打开,则新建一个Word li_ret = ole_object.ConnectToNewObject("Word.application") if li_ret <> 0 then MessageBox('错误','使用OLE控制WORD打印输出无法连接!') return end if ole_object.Visible = false end if if not fileexists(docfile) then messagebox('错误',docfile+"~r~n~r~n"+"拍卖成交确认书模板文件未找到!") return end if try ole_object.documents.open(docfile) catch (OLERuntimeError ex) messagebox('OLE错误',ex.getmessage()) ole_object.application.quit() //退出word //断开OLE连接 Ole_Object.DisConnectObject() Destroy Ole_Object return end try ...
