none
Excel COM-Interop crashes with Excel 2013 RRS feed

  • Frage

  • I did ExelAutomation with COMInterop for years successfully with Excel 2007. Now I switched to Excel 2013 and suddenly my software crashes.

    I have the following program logic with a very suspect Workaround

    1. Create xls-workbook and sheets
    2. Keep it hidden
    3. Exception at the following line:          myButton.Name = “abc”;

    I observe exceptions as this one:  {System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))
      
    Searching for 0x80028018 directs me to this page: https://support.microsoft.com/en-sg/help/320369/bug-old-format-or-invalid-type-library-error-when-automating-excel
    But all of the remedies (related to locales) do not remove the issue.

    My workaround is:

    1. Create xls-workbook
    2. Explicitely set it to “visible”
    3. Do NOT minimize the Excel-Window
    4. ….. it works as expected……             If I minimize the Workbook, it crashes at the same line as above.

    Very suspect. Seems to have nothing to do with locales, but with visibility of the workbook. 

    Do you have any idea ?





    • Bearbeitet Somigur Mittwoch, 19. April 2017 15:38
    Mittwoch, 19. April 2017 09:26

Alle Antworten

  • Hi Somigur,

    first of all , I want to suggest you to provide a sample demo code that can reproduce the issue on my side.

    so that I can make test with it and try to check whether I can reproduce the issue or not.

    the link mentioned by you is old and I find that they are using Windows 2000 and maybe office 2003.

    so it is possible that in newer version of Office bug get resolved by engineers.

    then also I want to confirm you below things.

    (1) is your method requires an LCID (locale identifier).

    (2) Are You running an English version of Excel. However, the regional settings for the computer are configured for a non-English language?

    if I will successfully reproduce the issue then we can provide the feedback to Excel user voice regarding this bug.

    other thing I want to confirm with you is that are you developing an Excel VSTO Addin or VSTO Workbook?

    you are talking about button. which type of button is it and where you place it?

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Donnerstag, 20. April 2017 06:14
    Moderator
  • First: Thank you for your Support !

    Here my info:

    INSTALLATION
         Windows 7 :  Region and Language
              Format = Germany
              Current Location = Germany
              Keyboards and Languages - Display language = English
      
         Excel 2013  : Language
              Editing Language = German (Enabled, installed)
              Display Language = Englisch
       
     
    TESTPROGRAM (with reference to Microsoft.Office.Interop.Excel, V15.0.0.0)
    using Excel = Microsoft.Office.Interop.Excel;
    namespace ExcelComTest {
        class Program {
            static void Main(string[] args) {

                Excel.Application _xclApp = new Excel.Application();
                _xclApp.Visible = true;
                Excel.Workbook _xclWorkBook = _xclApp.Workbooks.Add();
                Excel.Worksheet sheet = _xclWorkBook.Sheets[1];


                Excel.Range rng = sheet.get_Range("B2:D6");
                Excel.Button newButton = sheet.Buttons().Add(rng.Left, rng.Top, rng.Width, rng.Height);
                newButton.Name = "clickMe!";
            }
        }
    }

    REPRODUCING FAULT

    1. Set Breakpoint at line:   "newButton.Name = "clickMe!";
    2. Run the program
    3. Minimize the generated Excel
    4. Continue Debugging    <== Crash happens


    • Bearbeitet Somigur Donnerstag, 20. April 2017 07:53 code simplified
    Donnerstag, 20. April 2017 07:49
  • Hi Somigur,

    when I try to test the code, I get exception below.

    I try to activate the sheet.

    I try to activate the window but nothing works.

    so at last I try to maximize the window to solve the issue.

     _xclApp.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlMaximized;

    as work around you can currently check if the window is minimize then you can maximize it and then add button.

    you can submit your feedback regarding this issue to Excel user Voice

    Welcome to Excel’s Suggestion Box!

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Freitag, 21. April 2017 06:17
    Moderator
  • Deepak, thank you.

    I used the "Excel's Suggestion Box".

    Freitag, 21. April 2017 10:17