How to detect the language of MS Excel from C#

Posted by Babba on Stack Overflow See other posts from Stack Overflow or by Babba
Published on 2010-05-11T17:05:57Z Indexed on 2010/05/11 17:34 UTC
Read the original article Hit count: 291

Filed under:
|
|
|

If i try to use Excel from C# (interop) i receive error (HRESULT: 0x80028018) when current thread language is different from Excel language: so i need to set thread language, they must be the same.

Which is the best method to understand the language of Excel/Office?

1) registry (HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\LanguageResources\UILanguage ? How understand wich version (12.0/14.0/...?)

2) with Application like suggested here (http://stackoverflow.com/questions/2804556/how-to-detect-the-language-of-ms-excel) ? It's ok but i need a strong reference to a specific version Microsoft.Office.Core and so i can't do it for different versione of Office:

Excel.Application application = new Excel.Application();
int iUi = application.LanguageSettings.get_LanguageID(Microsoft.Office.Core.MsoAppLanguageID.msoLanguageIDUI);
MessageBox.Show(iUi.ToString());

3) other?

© Stack Overflow or respective owner

Related posts about c#

Related posts about interop