Excel programming of formulas and globalization problem

  • Thread starter Thread starter jmR
  • Start date Start date
J

jmR

I've created an .Net application that fill a excel sheet. For some of the
cells, my application write a formula instead of a direct value. I'm writing
somthing like :

oSheet2.Cells(x, y).formula = "=SOMME(CALC!A" & a & ":CALC!A" & b &
")/AY" & c

All this works fine on a FRENCH environment. It doesn't work on an ENGLISH
Excel environment.

My question is : How to do something that works with both French and English ?

Thanks in advance.
 
You app can only do what a human would do when entering a formula. The human
would have to know to use =SUM() in English and to use =SOMME() in French.

You app needs some kind of global flag to indate the language setting for
Office and pick the functions accordingly.
 
Thanks for your prompt reply. Then, do you known if there is a property in
excel application or worksheet object that could help me to detect the excel
language ?

Thanks in advance
 
I don't know.

However, within VBA, it is easy to test:

Sub languagetest()
Dim strg As String
Range("A1").Formula = "=SOMME(B1:B2)"
strg = Range("A1").Text
If strg = "#NAME?" Then
MsgBox ("Clearly not French")
End If
End Sub
 
I don't know about .net, but in VBA you can use the .Formula property with
the English formula and it will be translated automatically. Or you can use
the .FormulaLocal property and use the language of the application for the
formula.
 
Back
Top