Here you have a full example of how to call SetLocaleInfo from .Net. I won't copy here for brevity, it's a
http://took1.googlecode.com/svn-history/r87/trunk/Code/App.Dev/SetLocale.cs
Question
I'm trying to find a way to change the locale settings when opening Excel, or changing the entire system locale settings. I know it's bad practice to do this, so I'll just note that this is purely for automated testing reasons. We want to run our Excel add-in simulating multiple different locale settings to make sure it's handling all the functions properly (if there's a better way of doing this than changing settings please let me know!)
I know how to change the CurrentCulture of the thread, but that only seems to apply to our add-in, so functions of Excel called by our add-in run with the system locale settings.
There are 3 ways I've found that I thought might get this working, but one of them seems like an insanely bad idea, and the other two I can't manage to get working:
If anyone can provide any help it would be greatly appreciated, otherwise I guess these are just being left as manual tests!
Solution 2
Here you have a full example of how to call SetLocaleInfo from .Net. I won't copy here for brevity, it's a
http://took1.googlecode.com/svn-history/r87/trunk/Code/App.Dev/SetLocale.cs
OTHER TIPS
I would suggest creating several users on your computer and adjusting user locale settings accordingly to your test purposes for each user in Control Panel -> Region and Language. This basically allows setting a default language, and currency/number/date/time formats. If this is what you want, you can launch excel using a different user execution context by either runas
command, which requires a manual password entering, or in batch mode using psexec tool from SysInternals: http://technet.microsoft.com/en-us/sysinternals/bb897553
Make sure to specifycommand line options that load account's profile. Unfortumnately you can only adjust user locale settings per each user. System locale settings are defined per computer.