Little Changes: Excel Locale–again

I'm not sure if people realize how significant the fixing of the Excel locale issue is that I blogged about earlier:

This has been a huge adoption blocker for writing managed code against Excel that has been mentioned repeatedly by customers, books like the recent one by Stephen Bullen, and others.  We now have behavior in VSTO that makes developing in managed code just like the VBA experience--the locale is always kept at 1033 so your solution will work as expected in other locales.

We now expose as new Microsoft.Office.Tools.Excel.ExcelLocale1033Proxy.Wrap method to which you can pass the Type of the object you want to wrap and the object itself and get back a wrapped object that will always talk to Excel in the 1033 locale.  You can use this if you ever run into a case where you get an Excel object that isn't using the ExcelLocale1033Proxy and you want to force it to always be kept at 1033.

public static object Wrap(Type typeOfObject, object excelObjectToWrap)...



Comments (4)
  1. I agree that this removes what I consider to be the biggest job-stopper, and the introduction of edit-and-continue in VS2005 removes much of the continual shutdown-edit-restart pain of previous versions too. Together, those are two of the biggest pain points gone, so we might now be able to focus on how (and whether) to migrate from VBA to .NET. To that end, do you have any information on whether hybrid VBA/VSTO (callback) solutions are going to be supported?

    Also, if this wrapping is only for VSTO, are you going to provide an easy way for us to use the same mechanism for non-VSTO Excel automation projects?

  2. Eric Carter says:

    It is possible to have hybrid VBA/VSTO solutions. See for more information.

    Also, it would be possible to use the Wrap method from other automation projects by adding a reference to the appropriate assembly and then using the ExcelLocal1033Proxy.Wrap method.

  3. Hallgrim says:

    I found the following piece of code useful:

    private static T Wrap<T>(T instance) {

    return (T)ExcelLocale1033Proxy.Wrap(typeof(T), instance);


    I call this on my object whenever I get a runtime exception. This approach works, but it is quite annoying that I don’t know when I am supposed to Wrap and when not.

Comments are closed.

Skip to main content