Excel programming of formulas and globalization problem

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.
 
G

Gary''s Student

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.
 
J

jmR

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
 
G

Gary''s Student

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
 
N

Niek Otten

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top