none
ERROR:COM object that has been separatrd from it's underlyng RCW cannot be used , on open of MS Word RRS feed

  • Question

  • I am closing word document by following code

                        object dummy = System.Reflection.Missing.Value;
                        object dummy2 = (object)false;
                        wd.Quit(ref dummy2, ref dummy, ref dummy);                    
                        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(wd);

                       GC.Collect();

    After that , if i am reopening the MS Word , I am getting the above error at line

                if(wd == null) wd = new Word.ApplicationClass();
                try
                {
                    wd.CommandBars.AdaptiveMenus = false;  // This s generating error
                    wd.DocumentBeforeClose += new Word.ApplicationEvents4_DocumentBeforeCloseEventHandler(OnClose);
                    wd.DocumentOpen += new Word.ApplicationEvents4_DocumentOpenEventHandler(OnOpenDoc);
                    wd.ApplicationEvents4_Event_Quit += new Word.ApplicationEvents4_QuitEventHandler(OnQuit);               
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

               

    It's very urgent


    Wednesday, June 6, 2012 7:41 AM

Answers

  • Finally i got solution by  :               document.RemoveDocumentInformation(Microsoft.Office.Interop.Word.WdRemoveDocInfoType.wdRDIAll);

    After that i am able to quit the MSWORD.

    Please mark answers and useful posts to help other developers use the forums efficiently.




    Friday, June 8, 2012 1:14 PM

All replies

  • Hello,

    First off, set wd = null explicitely.

    Then try the same code with all COM add-ins turned off. To turn a COM add-in off, set LoadBehavior = 0 in {HKLM and HKCU}\Software\Microsoft\Office\Word\Addins\{an add-in}.

    In case this doesn't help, then check if calling wd.Quit() and releasing wd leaves WINWORD.EXE in the Processes list of the Task Manager window. If it does, this means your code doesn't release some other COM objects. Make sure that you detach event handlers before you release wd.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Wednesday, June 6, 2012 8:42 AM
  • WINWORD.EXE  Process not quieting from the list of the Task Manager window.

    how can i remove it from task manager ?


    Wednesday, June 6, 2012 10:04 AM
  • When in Task Manager, press {F1} to read help topics.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Wednesday, June 6, 2012 12:38 PM
  • Finally i got solution by  :               document.RemoveDocumentInformation(Microsoft.Office.Interop.Word.WdRemoveDocInfoType.wdRDIAll);

    After that i am able to quit the MSWORD.

    Please mark answers and useful posts to help other developers use the forums efficiently.




    Friday, June 8, 2012 1:14 PM