none
cannot open the existing file (Normal.dotm) RRS feed

  • Question

  • I am using Office 2010 in a C# environment.  I have an application the is creating may documents.  While the application is running the following message randomly appears on the screen. cannot open the existing file (Normal.dotm).

    The following exception is thrown Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))

    What causes this to happen and how can it be prevented?


    Leonard Swarczinski Software Developer Postal Center International

    Wednesday, September 11, 2013 6:33 PM

Answers

  • The error you report has to do with how the Word.Application is being managed. The code you show us doesn't contain that. (And please use the "Code" tool in the message toolbar for pasting code as generally, the result will be more readable.)

    The error message indicates that an instance of Word has not be released correctly and that your code is trying to re-use that object variable, but cannot because it hasn't been released.


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, September 13, 2013 1:21 PM
    Moderator

All replies

  • It's really difficult to say anything without any information on how you application is interacting with Word.

    My best guess would be that you're starting a new Word.Application instance for every document? That could cause issues such as you describe. In that case, a better approach would be to start one instance and re-use it.

    Even better would be to not use the Word.Application at all - generate the documents as files directly, leveraging the Office Open XML file format. The Open XML SDK can help with this. For more information, visit OpenXMLDeveloper.org


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, September 12, 2013 7:34 AM
    Moderator
  • I am starting a new application for each document.  I created one application and passed it as a paramenter to the code that builds the documents.  Start on and resue it.  However when I try to open the document I get the following error.

    Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA).

       

    internal void CreateDocument(string OutputFile, ref Word.Application wordApp, out Word.Document aDoc)

            

    object missing = Missing.Value;

        

    //  create Word application object


         

    //wordApp = new Word.ApplicationClass();


         

     Doc =

    null;

         

    //  create & define filename object with temp.doc


         

    object filename = OutputFile;

         

    //  if temp.doc available


         

    if (File.Exists((string)filename))

          {

           

    object readOnly = false;

           

    object isVisible = false;

            wordApp.Visible =

    false;

            aDoc = wordApp.Documents.Open(

    ref filename, ref missing,

             

    ref readOnly, ref missing, ref missing, ref missing,

             

    ref missing, ref missing, ref missing, ref missing,

             

    ref missing, ref isVisible, ref missing, ref missing,

             

    ref missing, ref missing);

            aDoc.Activate();

            wordApp.ScreenUpdating =

    false;

          }

        }


    Leonard Swarczinski Software Developer Postal Center International

    Thursday, September 12, 2013 8:15 PM
  • The error you report has to do with how the Word.Application is being managed. The code you show us doesn't contain that. (And please use the "Code" tool in the message toolbar for pasting code as generally, the result will be more readable.)

    The error message indicates that an instance of Word has not be released correctly and that your code is trying to re-use that object variable, but cannot because it hasn't been released.


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, September 13, 2013 1:21 PM
    Moderator
  • That is exactly what the problem was.  I resolved the errors by eliminating all starts and stops of the application.

    Leonard Swarczinski Software Developer Postal Center International

    Friday, September 20, 2013 2:38 PM