getting Call was rejected by callee exception in VSTO ( Word Application )

2

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

c#-4.0
ms-word
vsto
asked on Stack Overflow Mar 17, 2012 by Javid_p84 • edited Nov 7, 2012 by Javid_p84

2 Answers

6

I turned off these features of word :

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

now it's working perfectly

answered on Stack Overflow Mar 18, 2012 by Javid_p84 • edited Nov 7, 2012 by Javid_p84
0

I had same problem when my office became un-activated; and each time when I launch Word I was presented dialogue window about activation failure. As soon as I activated Office, this window no longer appeared and my app worked as usual.

answered on Stack Overflow Feb 9, 2021 by Michael Snytko

User contributions licensed under CC BY-SA 3.0