python 报错 被呼叫方拒绝接收呼叫_如何解决‘被呼叫方拒绝接收呼叫’的错误(50分)...

我使用DELPHI调用WORD,打开一个文件,编辑后,点击一个按钮,将该文件保存到数据库。现在出现的问题是,程序启动后第一次启动WORD,使用没有任何问题,再次启动WORD则出现class EOleSysError of message‘被呼叫方拒绝接收呼叫’的错误。我想可能是WORD关闭造成的,因为重新启动程序后,再启动WORD又好了,第二次调用又是一样的错误。

后面是代码,请各位帮忙看看!

//启动WORD模板进行处理

try

confirmconversions:= false;

readonly:= true;

addtorecentfiles:= false;

passworddocument:= '';

passwordtemplate:= '';

revert:= true;

writepassworddocument:= '';

writepasswordtemplate:= '';

format:= wdopenformatdocument;

encoding:='';

visible:=true;

wordapplication.Documents.Open(filename,confirmconversions,readonly,addtorecentfiles, passworddocument,passwordtemplate,revert,writepassworddocument,writepasswordtemplate,format,encoding,visible);

{assign worddocument component}

itemindex := 1;

worddocument.connectto(wordapplication.documents.item(itemindex));

{turn spell checking of because it takes a long time if enabled and slows down winword}

wordapplication.options.checkspellingasyoutype := false;

wordapplication.options.checkgrammarasyoutype := false;

wordapplication.connect;

except

messagedlg('可能没有安装好WORD', mterror, [mbok], 0);

abort;

end;

wordapplication.visible := true;

......处理WORD文件.........

下面是保存到数据库的代码:

begin

filename:='c:/temp/temp1.doc';

fileformat:=wdformatdocument;

addtorecentfile:=false;

worddocument.SaveAs(filename,fileformat,addtorecentfile);

//worddocument.Close;

//worddocument.Disconnect;

wordapplication.Quit;

wordapplication.Disconnect;

str:=tmemorystream.Create;

str.LoadFromFile(filename);

str.Position:=0;

tidentifypaper.Close;

tidentifypaper.Open;

if tidentifypaper.Locate('identifypaperno',paperno,[]) then

begin

tidentifypaper.Edit;

tblobfield(tidentifypaper.FieldByName('doc')).LoadFromStream(str);

try

tidentifypaper.Post;

tidentifypaper.Close;

saveornot:=true;

showmessage('保存成功!');

finally

str.Free;

deletefile(filename);

tidentifypaper.Close

end;

end;

end;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值