Globalization and Localization Problem with Excel and VSTO 2005.
Hi,
We created a new Excel application in VSTO and Excel Professional 2003 SP1 for our business requirement. We used the Excel formals in order to evaluate several requirements. These are all working fine if the settings were there in en-US culture. But when we tried to run the Excel application after changing the settings to any other culture apart from en-US we are getting following error when we tried to access the Formulas.
Error:
“HRESULT: 0x800A03EC“
When we searched in we could able to get this link explaining about how to Globalizing the office applicaitons.
See the section "Using Reflection for COM Interop Calls" under which we are having three methods "SetPropertyInternational", "GetPropertyInternational" and "InvokeMethodInternational". We implemented these methods into our applicaiton and called the InvokeMethodInternational for executing a simple function "=SUM(B1:C1)" then we are getting following error.
Exception:Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
OK
The code which we used is
private static object InvokeMethodInternational(object target, string name,
params object[] args)
{
return target.GetType().InvokeMember(name,
System.Reflection.BindingFlags.InvokeMethod |
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance,
null, target, args, new System.Globalization.CultureInfo(1033));
}
private void button1_Click(object sender, EventArgs e)
{
try
{
Excel.Range cellRange;
cellRange = (Excel.Range)Globals.ThisWorkbook.ThisApplication.get_Range("B1", Type.Missing);
SetPropertyInternational(cell, "Value", 1);
cellRange = (Excel.Range)Globals.ThisWorkbook.ThisApplication.get_Range("C1", Type.Missing);
SetPropertyInternational(cell, "Value", 2);
cellRange = (Excel.Range)Globals.ThisWorkbook.ThisApplication.get_Range("D1", Type.Missing);
cellRange.Formula = "=SUM(B1:C1)";
InvokeMethodInternational(cellRange.Validation, "Add",
new object[] { Excel.XlDVType.xlValidateDecimal, Excel.XlDVAlertStyle.xlValidAlertInformation,
System.Reflection.Missing.Value,System.Reflection.Missing.Value, "=SUM(B1:C1)" });
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
Please kindly give us the solution how to use "InvokeMethodInternational" in order to invoke Excel Formulas.
Note: We also installed MUI Packs for office 2003 to support multiple languages, but even we are getting this problem.
Thanks

