Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect the language in which Excel is setup and show it in a cell of the file

I'm designing a set of related excel file which are related between them. The objective is that the macros which refere to each other document, can work in any given computer/path. For this reason I have used a set of relative path which lets the macros work well.

I have used the follwoing functions:

=+CELDA("nombrearchivo";$A$1)

"nombredearchivo" means "filename" in english.

The problem here is that this function only works when the computer is setup in Spanish, but when the files are transferred to a English set up computer, it translates de function CELDA to CELL, but not the "nombrearchivo".

To solve it I have thought about trying to show in cell the language in which Excel is setup and then write an if function with three main languages which would display the nombrearchivo, filename or the same in any other language.

Is it possible to show in a cell the language in which excel is setup??

The objective is that the macros ccan work at any given computer and path.

like image 915
Alex O Avatar asked Jul 25 '19 09:07

Alex O


People also ask

How do you determine the language of a cell in Excel?

On the Review tab, in the Language group, click Language. Click Set Proofing Language. In the Language dialog box, select the Detect language automatically check box. Review the languages shown above the double line in the Mark selected text as list.

How do I change the language in Excel?

Click File > Options > Language. In the Set the Office Language Preferences dialog box, under Choose Display and Help Languages, choose the language that you want to use, and then select Set as Default.

What coding language does Excel macros use?

The macros that you create in Excel would be written in the programming language VBA (Visual Basic for Applications). You will learn about the Excel macro code in later chapters. As you are aware, when there is an executable code, there is a threat of viruses.

How to detect a language in Excel?

The English name of that function is FORMULATEXT (please find the translated function name of your own language). This means that we can use this function to create our own way to detect a language. If you wnat to create an international sheet, it is a lot of work, but of you only need to support 2 or 3 languages, it can be used.

Is it possible to request the language of the Excel formula?

So we cannot request the language, however, from Excel 2016 and above, there is a possibility to get a formula in text. The English name of that function is FORMULATEXT (please find the translated function name of your own language).

What language is used to write Microsoft Excel?

Most Microsoft product that are legacy products tends to be written in C++ but as of late C-Sharp. The OS itself is written in C++. Originally Answered: What is used to write excel? MS Office was developed using assembler, then development moved to C, later, when C++ arose, everything new was done using C++.

How to change language in Excel worksheet?

Now select Language from the left option menu from the pop-up dialogue box opened. Now, search for the language in which you want to change the language of your Excel worksheet. Note: You will only find Languages in search, which are installed in your system.


Video Answer


2 Answers

This will return you a lang code go here to understand what LCID is..

And Here to get the list of all LCID code signification

for exemple : 1036 = French - Standard

dim lang_code as long
lang_code = Application.LanguageSettings.LanguageID(msoLanguageIDUI)

Application.LanguageSettings Doc Here

like image 129
TourEiffel Avatar answered Sep 23 '22 21:09

TourEiffel


This answer is totally extracted from this source:

https://www.mrexcel.com/forum/excel-questions/617870-language-code-french-spanish-spanish.html

So all credits go to original author Leith Ross:

' Written: March 01, 2012
' Author:  Leith Ross
' Summary: Converts a Language Code Identifier (LCID) into the language name.

Private Declare Function GetLocaleInfoA _
    Lib "kernel32.dll" _
        (ByVal Locale As Long, _
         ByVal LCType As Long, _
         ByVal lpLCData As String, _
         ByVal cch As Long) _
    As Long

Function GetLanguageName(ByVal LCID As Long) As String

    Const LOCALE_SENGLANGUAGE As Long = &H1001
    Const LOCALE_SENGCOUNTRY As Long = &H1002

    Dim Buffer As String
    Dim BuffSize As Long
    Dim RetVal As Long

        BuffSize = GetLocaleInfoA(LCID, LOCALE_SENGLANGUAGE, 0, 0)
        Buffer = String(BuffSize, Chr(0))

        RetVal = GetLocaleInfoA(LCID, LOCALE_SENGLANGUAGE, Buffer, BuffSize)

        If RetVal > 0 Then GetLanguageName = Left(Buffer, BuffSize - 1)

End Function

To test it, just type in a cell =GetLanguageName(1034) (decimal value) but it works also with Hex value, like =GetLanguageName("&H40A")

I got this in my Excel:

enter image description here

And to get the decimal number you need to type, you can use something like this:

Function GetLanguage() As String
GetLanguage = GetLanguageName(Application.LanguageSettings.LanguageID(msoLanguageIDUI))
End Function

So typing in a cell GetLanguage() will return the user's language.

enter image description here

Hope you can adapt this to your needs.

like image 26
Foxfire And Burns And Burns Avatar answered Sep 24 '22 21:09

Foxfire And Burns And Burns