Excel Automation Locale Issues

If you are doing Excel Automation, and are having errors like "Exception from HRESULT: 0x800A03EC" or "Old format or invalid type library" probably it’s a location problem.
 
One solution is to force a culture change when using excel objects, but there’s a better and simplified way, that only requires to instantiate the Excel.Application object like this:
 

Excel.Application excelApp = (Excel.Application)Microsoft.Office.Tools.Excel.ExcelLocale1033Proxy.Wrap(typeof(Excel.Application), new Excel.Application());

With this all the comunication with excel via this object will be done in locale 1033, it basically creates a proxy that comunicate with Excel always in locale 1033 like in VBA.

For more detail check:

http://blogs.msdn.com/eric_carter/archive/2005/06/15/429515.aspx

http://blogs.msdn.com/eric_carter/archive/2005/08/25/453680.aspx

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s