WSAddInDev
Posts: 38
Joined: 2013-05-13
|
Hi
I found another way.
1. read the current excel version from registry
RegistryKey CurrentExcelversionKey = Registry.ClassesRoot.OpenSubKey("Excel.Application", false).OpenSubKey("CurVer", false);
string strCurrVersion = CurrentExcelversionKey.GetValue("").ToS tring();
2. read the current excel locale from registry
[CODE]
strRegistryPath = string.Format(@"Software\Microsoft\Office\{0}.0\Common\LanguageResources", 12);
RegistryKey rkeyUILanguage = Registry.CurrentUser.OpenSubKey(strRegistryPath, false);
if (rkeyUILanguage != null)
{
int.TryParse(rkeyUILanguage.GetValue("UILanguage", false).ToS tring(), out intLocaleId);
} |
|
Andrei Smolin
Add-in Express team
Posts: 18183
Joined: 2006-05-11
|
That's great! Thank you for sharing the solution!
Regards from Belarus (GMT+3),
Andrei Smolin
Add-in Express Team Leader |
|
WSAddInDev
Posts: 38
Joined: 2013-05-13
|
Hi
I found another way.
1. read the current excel version from registry
RegistryKey CurrentExcelversionKey = Registry.ClassesRoot.OpenSubKey("Excel.Application", false).OpenSubKey("CurVer", false);
string strCurrVersion = CurrentExcelversionKey.GetValue("").ToS tring();
2. read the current excel locale from registry
strRegistryPath = string.Format(@"SoftwareMicrosoftOffice{0}.0CommonLanguageResources", <VersionNumberFoundAbove>);
RegistryKey rkeyUILanguage = Registry.CurrentUser.OpenSubKey(strRegistryPath, false);
if (rkeyUILanguage != null)
{
int.TryParse(rkeyUILanguage.GetValue("UILanguage", false).ToS tring(), out intLocaleId);
}
Now since we have found the LCID . we can find the corresponding locale from LCIDS present at http://support.microsoft.com/kb/221435
Set the Current Thread language with that locale before This.InitializeComponent() in AddinModule Constructor.
Hence the addin express ribbon will pick language of excel.
This works perfectly fine. |
|