Insert a formula in a different language RRS feed

  • Question

  • Hello all,

    I am building an Excel sheet with I insert formulae, set cell format and so on...

    I use the following syntax :

    myRange.Formula = "=SUM(R1C:R[-1]C)"
    myRange.Style = "Percent"

    However, when using Excel in a different language, the formulae and the cell style are not recognized ! For example, in French, it must be :

    myRange.Formula = "=SOMME(L1C:L[-1]C)" 
    myRange.Style = "Pourcentage"

    How may I overcome this ? I'm thinking of :

    • Entering formulae and Cell style in a different way, an "international" way, if possible. But how ?
    • Testing the version of Excel and entering the formulae corresponding to the language. But how to test the Excel language ?

    Any other idea ?


    Friday, March 2, 2012 5:08 PM

All replies

  • Hi,

    Would you like to tell us what kind of project you are working with? As VSTO document-level solution has already solved the issue for us. Please have a look at this blog:

    How VSTO solves the Excel LCID or Locale issue in the June CTP build 

    On the other hand, I have tested something similar on my Chinese version Office and no such issue like you said happened. So you really be more specify about your project, is this a VSTO add-in project or just an Excel object model automation project (no VSTO involved)?

    I look forward to hearing of you soon.

    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 5, 2012 6:22 AM
  • Thanks Calvin,

    I don't think I am using VSTO. How may I be sure ?

    I fill an Excel file by using such code :

    Dim myExcel = New Microsoft.Office.Interop.Excel.Application

    I did another test this morning. If I use, for example, a Style name which is not in the language of the Excel, it crashes.

    myRange.Style = "Pourcentage" (percent in French) 

    I receive "COMException was unhandled".
    Monday, March 5, 2012 9:13 AM