MS Word 2013 Add In RRS feed

  • Question

  • Hello.

    We've built a Ribbon Add-In for MS Word 2013.

    In this Add-In there is a control that lists some file names that the Add-In reads from an Excel file.

    When the Add-In finishes getting the file names from the Excel file it closes it

    We are getting an exception when our Add-In attempts to close this file.

    public static void closeExcel()
    if (fileDescriptionXLS != null)
    fileDescriptionXLS.Close(missing, missing, missing);
    fileDescriptionXLS = null;
    if (excelApp != null)
    excelApp = null;

    The first error goes something like this:

    Server stack trace: 
       at Microsoft.Office.Interop.Excel._Workbook.Close(Object SaveChanges, Object Filename, Object RouteWorkbook)
       at sapToolboxV2.SAPFileController.closeExcel()
       at sapToolboxV2.SAPLibraryController.parseLibrary(String libraryLocation, Int32 numTreatments)
       at sapToolboxV2.SAPUserControl.load_library_table(Int32 numTreatments)
       at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
       at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
       at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(System.Runtime.Remoting.Messaging.Message, Boolean)
       at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(System.Object, System.Runtime.Remoting.Proxies.MessageData ByRef)
       at sapToolboxV2.SAPUserControl+load_library_delegate.EndInvoke(System.IAsyncResult)
       at sapToolboxV2.SAPUserControl.load_library_complete(System.IAsyncResult)
       at System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage)
       at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessageSink)
       at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(System.Object)
       at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
       at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
       at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
       at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       at System.Threading.ThreadPoolWorkQueue.Dispatch()
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

    The second error:

    Application: WINWORD.EXE
    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.InvalidCastException



    Thursday, May 14, 2015 9:37 PM

All replies

  • Hi,

    Where the method closeExcel is called? How did you initialize the control list the file names? Also can you reproduce this issue everytime?

    It is much appreciate to share a demo code to help us reproduce this issue.

    Also I am not able to undestand the second error about System.InvalidCastException, did you mean this error was caused after exception closing Excel?

    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.

    Friday, May 15, 2015 3:03 AM