Microsoft KB Archive/278957

= PPT2000: Macro to Detect Keyboard Language =

Article ID: 278957

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft PowerPoint 2000 Standard Edition

-



This article was previously published under Q278957



SUMMARY
The Microsoft Visual Basic for Applications macro in this article demonstrates how to determine the keyboard language setting. You may need to determine this setting before you display a message or type characters in a shape.



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.

NOTE: The following macro examples work only in PowerPoint. Visual Basic for Applications macros are not supported by the Microsoft PowerPoint Viewer. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

Sample Code
 On the Tools menu, point to Macro, and then click Visual Basic Editor. On the Insert menu, click Module.  Type the following code in the module: Option Explicit

' ' Declare API calls. ' Public Declare Function GetKeyboardLayout Lib &quot;user32&quot; _ (ByVal dwLayout As Long) As Long ' ' CopyMemory takes the value in Source, and extracts the byte ' values from the number of bytes indicated by Length from ' Source. ' Public Declare Sub CopyMemory Lib &quot;kernel32&quot; Alias &quot;RtlMoveMemory&quot; _ (Destination As Any, Source As Any, ByVal Length As Long)

Function LowWord(ByVal lOriginalValue As Long) As Integer ' ' Returns the low word of a Long value. Therefore, if GetKeyboardLayout ' returns the value 67699721, this function extracts the decimal ' value of the of the first word in the lOriginalValue variable, and ' returns 1033 as the value of the first word of lOriginalValue. ' ' The Long data type is a 4-byte Integer that ranges in value from ' -2,147,483,648 to 2,147,483,647. A word is two bytes long. '  CopyMemory LowWord, lOriginalValue, 2 End Function

Sub test Dim lKeyboardValue As Long Dim lResp As Long Dim lLangCode As Long Dim strLang As String ' ' Initialize lKeyboardValue to zero '  lKeyboardValue = 0 ' ' Get the Keyboard Layout value. '  lResp = GetKeyboardLayout(lKeyboardValue) ' ' Extract the language code value. '  lLangCode = LowWord(lResp) ' ' Using the Select Case statement, match the code to one of the ' standard keyboard language types available to Microsoft Windows. '  Select Case lLangCode Case 1028 strLang = &quot;Taiwan - Chinese, Traditional&quot; Case 1029 strLang = &quot;Czech - Czech&quot; Case 1030 strLang = &quot;Denmark - Danish&quot; Case 1031 strLang = &quot;Germany - German&quot; Case 1032 strLang = &quot;Greece - Greek&quot; Case 1033 strLang = &quot;US - English&quot; Case 1034 strLang = &quot;Spain - Spanish&quot; Case 1035 strLang = &quot;Finland - Finnish&quot; Case 1036 strLang = &quot;France - French&quot; Case 1037 strLang = &quot;Israel - Hebrew&quot; Case 1038 strLang = &quot;Hungary - Hungarian&quot; Case 1040 strLang = &quot;Italy - Italian&quot; Case 1041 strLang = &quot;Japan - Japanese&quot; Case 1042 strLang = &quot;Korea - Korean&quot; Case 1043 strLang = &quot;Benelux - Dutch&quot; Case 1044 strLang = &quot;Norway - Norwegian&quot; Case 1045 strLang = &quot;Poland - Polish&quot; Case 1046 strLang = &quot;Brazil - Portuguese&quot; Case 1049 strLang = &quot;Russia - Russian&quot; Case 1051 strLang = &quot;Slovakia - Slovakian&quot; Case 1053 strLang = &quot;Sweden - Swedish&quot; Case 1054 strLang = &quot;Thailand - Thai&quot; Case 1055 strLang = &quot;Turkey - Turkish&quot; Case 1060 strLang = &quot;Slovenia - Slovenian&quot; Case 2052 strLang = &quot;China - Chinese, Simplified&quot; Case 2057 strLang = &quot;UK - English&quot; Case 2060 strLang = &quot;Benelux - French&quot; Case 2070 strLang = &quot;Portugal - Portuguese&quot; Case 3081 strLang = &quot;Australia - English&quot; Case 3084 strLang = &quot;Canada - French&quot; Case 4105 strLang = &quot;Canada - English&quot; Case 5129 strLang = &quot;New Zealand - English&quot; Case 13321 strLang = &quot;Philippines - English&quot; Case 14345 strLang = &quot;Indonesia - English&quot; Case 15369 strLang = &quot;Hong Kong SAR - English&quot; Case 16393 strLang = &quot;India - English&quot; Case 17417 strLang = &quot;Malaysia - English&quot; Case 18441 strLang = &quot;Singapore - English&quot; Case 58378 strLang = &quot;LatAm - Spanish&quot; Case 58380 strLang = &quot;North Africa - French&quot; Case Else strLang = &quot;Not listed&quot; End Select ' ' Display a Message box with the language code and name. '  MsgBox &quot;The Keyboard language is: &quot; & lLangCode & &quot;: &quot; & strLang End Sub 

Additional query words: vba

Keywords: kbdtacode kbhowto KB278957

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.