Microsoft KB Archive/111388

= Creating Macros for Different Language Versions =

Article ID: 111388

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition
 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q111388





SUMMARY
In Microsoft Excel, you can determine the country code that corresponds to the version of Microsoft Excel you are running. These country codes can be helpful in creating custom applications.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Different versions of Microsoft Excel are currently available in over thirty international languages. These languages and their corresponding country codes are listed below:                         Country Code and Language             Countries/Regions to which Code Belongs -  Arabic                966 (Saudi Arabia) Czech                42  (Czech Republic) Danish               45  (Denmark) Dutch                31  (The Netherlands) English              1   (The United States of America) Farsi                982 (Iran) Finnish              358 (Finland) French               33  (France) German               49  (Germany) Greek                30  (Greece) Hebrew               972 (Israel) Hungarian            36  (Hungary) Indian               91  (India) Italian              39  (Italy) Japanese             81  (Japan) Korean               82  (South Korea) Norwegian            47  (Norway) Polish               48  (Poland) Portuguese (Brazil)  55  (Brazil) Portuguese           351 (Portugal) Russian              7   (Russian Federation) Simplified Chinese   86  (People's Republic of China) Spanish              34  (Spain) Swedish              46  (Sweden) Thai                 66  (Thailand) Traditional Chinese  886 (Taiwan) Turkish              90  (Turkey) Urdu                 92  (Pakistan) Vietnamese           84  (Vietnam) The codes shown above are derived from the Country Codes used by the telephone system in the United States of America.

In a custom application, it may be necessary to determine which language version of Microsoft Excel is running. For example, if you are writing a custom application for your company, which has offices in two different countries, the country code would make it possible to write a single macro for both offices. You could display different dialog boxes based on which language version of Microsoft Excel is being used. Below are examples of returning and using the country code in a Microsoft Visual Basic for Applications macro and an XLM macro.

Sample Visual Basic Procedure
In Microsoft Excel versions 5.0 and later you can use the Application.International function to return information about the current country and international settings of Microsoft Excel. The built- in constant "xlCountryCode" will return the country code of the version of Microsoft Excel you are running.

Below is a macro example that will return the country code and will then, based on that code, display "Hello" in the appropriate language: Sub Code Country_Code = Application.International(xlCountryCode) If Country_Code = 1 Then MsgBox ("Hello") ElseIf Country_Code = 34 Then MsgBox ("Hola") End If  End Sub

XLM Macro Code Example
In Microsoft Excel version 4.0, the GET.WORKSPACE function can be used to return information about the workspace. GET.WORKSPACE has one argument, type_num. Type_Num is a number specifying the type of workspace information you want.

To return the country code of the version of Microsoft Excel you are running, use the type number of 37. Type 37 returns a 45-item horizontal array of the items related to country versions and settings. You must index this array to return a specific item. The country code is the first item in this array.

Below is a macro example that will index the array of items returned by GET.WORKSPACE(37) to get the country code and then, based on that code, display "Hello" in the appropriate language:

A1: Code_Macro

A2: =INDEX(GET.WORKSPACE(37),1)

A3: =IF(A2=1)

A4: =ALERT("Hello")

A5: =ELSE.IF(A2=34)

A6: =ALERT("Hola")

A7: =END.IF

A8: =RETURN

