XL: Creating Macros for Different Language Versions

ID: Q111388


The information in this article applies to:
  • Microsoft Excel for Windows, versions 4.0, 4.0a, 5.0
  • Microsoft Excel for the Macintosh, versions 4.0, 5.0
  • Microsoft Excel 98 Macintosh Edition
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Excel 97 for Windows


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, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
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()


REFERENCES

"Function Reference," version 4.0, pages 209-212

Additional query words: 4.00a foreign XL7 XL5 XL97

Keywords : kbprg kbdta kbdtacode PgmOthr PgmHowto KbVBA
Version : MACINTOSH:4.0,5.0,98; WINDOWS:4.0,4.0a,5.0,7.0
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.