none
C# interop and culture

    Question

  • wb = ExcelHelper.oExcelApp.Workbooks.Add();


    Hello,

    I have a shared Excel addin written in C# using Microsoft.Office.Interop.Excel (version 12).

    I'm using german Excel on german Windows 7.

    This addin adds several menu items to Excel.

    With one I have a strange problem.

    When this one item is invoked,

    I set System.Threading.Thread.CurrentThread.CurrentCulture to en-US at the beginning.

    several lines later I execute

    wb = ExcelHelper.oExcelApp.Workbooks.Add();

    after that System.Threading.Thread.CurrentThread.CurrentCulture  is now de-DE !

    Therefore I set System.Threading.Thread.CurrentThread.CurrentCulture again to en-US.

    Some lines latter I call application.run and after this call System.Threading.Thread.CurrentThread.CurrentCulture  is now again de-DE !

    This behaviour of application.run does not happen without Workbooks.Add().

    So

    1) How can I avoid that application.run resets System.Threading.Thread.CurrentThread.CurrentCulture after

       Workbooks.Add() ?

    2)  How can I avoid that Workbooks.Add() resets System.Threading.Thread.CurrentThread.CurrentCulture  ?

    with best regards

      Hendrik

    Wednesday, December 12, 2012 10:22 AM

All replies