tags:

views:

15

answers:

0

I'm saving the current document with save as, after that I want to close document with document.close method, close control and finally quit application with Application.Quit method. However after execution of Application.Quit it throws an exception called RPC_E_DISCONNECTED, what does it mean how to solve ? thanks

objWinWordControl.document.SaveAs(ref FileName, ref FileFormat, ref LockComments, ref missing,
                    ref AddToRecentFiles, ref missing, ref ReadOnlyRecommended, ref EmbedTrueTypeFonts,
                    ref SaveNativePictureFormat, ref SaveFormsData, ref SaveAsAOCELetter);

                object saveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdSaveChanges;
                object originalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdWordDocument;
                object routeDocument = null;
                if (objWinWordControl != null)
                {
                    objWinWordControl.document.Close(ref saveChanges, ref originalFormat, ref routeDocument);
                    objWinWordControl.CloseControl();
                    objWinWordControl.document.Application.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
                }