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
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.
User contributions licensed under CC BY-SA 3.0