Setting Range.Formula localized Office issue

Add-in Express™ Support Service
That's what is more important than anything else

Setting Range.Formula localized Office issue
 
Stefan Hunziker


Guest


Hi

if I set the formula of a given cell using myRange.Formula = formulaText; then this only works if the culture of my Excel corresponds with the regional settings. KB320369 (http://support.microsoft.com/kb/320369) describes a workaround. This workaround did a good job in Excel 2007 but now in Excel 2010 throws an error (System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC). Find here the code segment:



            try
            {
                myAddIn.excelApp.ActiveCell.Formula = text;
            }
            catch
            {
                // Workaround for http://support.microsoft.com/kb/320369
                System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                myAddIn.excelApp.ActiveCell.Formula = text;
                System.Threading.Thread.CurrentThread.CurrentCulture = oldCI;
            }


do you have an idea?

thanks in advance

kind regards
Stefan
Posted 08 Mar, 2011 09:30:47 Top
Stefan Hunziker


Guest


ok, found...

my error was hard setting the new culture info to "en-US" instead of using excelApp.LanguageSettings.get_LanguageID(Office.MsoAppLanguageID.msoLanguageIDUI) as described in this blog article: http://www.add-in-express.com/creating-addins-blog/2009/02/13/old-format-invalid-type-library/

never mind

Stefan
Posted 09 Mar, 2011 01:00:58 Top
Eugene Astafiev


Guest


Hi Stefan,

You broke the ice! Good luck with your add-in project!
Posted 09 Mar, 2011 04:54:11 Top