在VSTO(Word应用程序)中被调用异常拒绝了调用 [英] getting Call was rejected by callee exception in VSTO ( Word Application )

查看:461
本文介绍了在VSTO(Word应用程序)中被调用异常拒绝了调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经3天了,我愚弄VSTO(Word应用程序)



我想在一个word文档中创建一个报告。我已经在模板文档中设置了一些书签。
,所以我的应用程序只打开模板文档并搜索每个书签,并用word文档中的表或文本替换书签。



我打开字样:

  application = new Application 
{
DisplayAlerts = false,
WindowState = WdWindowState.wdWindowStateMaximize,
Visible = false,
CheckLanguage = false,
DisplayAlerts = WdAlertLevel.wdAlertsNone,
ScreenUpdating = true,
};

CurrentDocument = application.Documents.Open(templateFilePath,false,false,false);

但是,在某些插入后,应用程序正在通过以下方式查找其他书签:

  if(!CurrentDocument.Bookmarks.Exists(bookmarkTitle))
return;

我得到以下异常:



被呼叫者拒绝了来电。 (来自HRESULT的异常:0x80010001(RPC_E_CALL_REJECTED))



任何想法如何摆脱它?
提前感谢

解决方案

我关闭了这些功能:

  CurrentDocument.ShowGrammaticalErrors = false; 
CurrentDocument.ShowRevisions = false;
CurrentDocument.ShowSpellingErrors = false;

现在效果很好

It's been 3 days that I'm fooling around VSTO (Word application)

I want to create a report in a word document. I already set some bookmarks in the template document. so my application just opens the template document and search for the each bookmark and replace the bookmark with a table or text in the word document.

I open the word like :

application = new Application
                              {
                                  DisplayAlerts = false,
                                  WindowState = WdWindowState.wdWindowStateMaximize,
                                  Visible = false,
                                  CheckLanguage = false,
                                  DisplayAlerts = WdAlertLevel.wdAlertsNone,
                                  ScreenUpdating = true,
                              };

CurrentDocument = application.Documents.Open(templateFilePath, false, false, false);

however, after some inserts, when application is looking for other bookmarks via :

if (!CurrentDocument.Bookmarks.Exists(bookmarkTitle))
                return;

I get the following exception :

Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))

Any idea how to get rid of it? Thanks in advance

解决方案

I turned off these features of word :

    CurrentDocument.ShowGrammaticalErrors = false;
    CurrentDocument.ShowRevisions = false;
    CurrentDocument.ShowSpellingErrors = false;

now it's working perfectly

这篇关于在VSTO(Word应用程序)中被调用异常拒绝了调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆