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.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2005_ta/html/OfficeVSTOGlobalization.asp

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

[2977 byte] By [VDeevi] at [2007-12-16]
# 1
There are some errors in the code, so it is hard to say what exactly does not work.

Here's the code that worked on my machine:

Excel.Range cellRange;

cellRange = (Excel.Range)Globals.ThisWorkbook.ThisApplication.get_Range("B1", System.Type.Missing);

SetPropertyInternational(cellRange, "Value", 1);

cellRange = (Excel.Range)Globals.ThisWorkbook.ThisApplication.get_Range("C1", System.Type.Missing);

SetPropertyInternational(cellRange, "Value", 2);

cellRange = (Excel.Range)Globals.ThisWorkbook.ThisApplication.get_Range("D1", System.Type.Missing);

SetPropertyInternational(cellRange, "Formula", "=SUM(B1:C1)");

InvokeMethodInternational(cellRange.Validation, "Add",

new object[] {

Excel.XlDVType.xlValidateDecimal,

Excel.XlDVAlertStyle.xlValidAlertInformation,

Excel.XlFormatConditionOperator.xlEqual,

"=SUM(B1:C1)",

System.Reflection.Missing.Value });


Hope this helps,
iouri
--
This posting is provided "AS IS" with no warranties, and confers no rights.

IouriSimernitski-MSFT at 2007-9-9 > top of Msdn Tech,Visual Studio Tools for Office,Visual Studio Tools for Office...