Interop Excel Close Workbook Error RRS feed

  • Question

  • Hi,

    I get the below error when calling the Workbook Close method...

    wb.Close(true, Missing.Value, Missing.Value);

    Error: COM object that has been separated from its underlying RCW cannot be used

    What does this mean?


    Tuesday, August 25, 2015 5:18 PM


  • Hi obrienkev,

    Based on the error message, it seems that the underlying RCW has been released. Please ensure that don't release the Com object before that there is still the reference in the managed code.

    And here is incorrect sample for your reference:

     string fileName = @"C:\Users\v-fexue\Desktop\sdf.docx";
                string insertText="hello Word!";
                Word.Application word = new Word.Application();
                Word.Document doc=word.Documents.Open(fileName);
                Word.Options op;
    'remove code below will fixt this issue            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(doc);

    If you still have the issue, would you mind sharing a code sample to help us narrow down this issue?

    Hope it is helpful.

    Regards & Fei

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, August 26, 2015 3:29 AM