Using Hebrew in a Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I need to be able to write hebrew letters to an excel spreadsheet from my
macro. I already have hebrew support installed on Windows XP.
What is the simplest way to do this?
I noticed I can't type in hebrew withen the Macro - is there a way to hard
code any text?

Thank you
 
Whilst you cannot type Hebrew (or rather any non-ANSI text) in the VBE, you
can work with its Unicode numbers, either Hex or decimal and the ChrW
function.
If you are bring this Hebrew text into VBA from outside (a text file or some
other app) look into using Byte arrays and StrConv.

Dim Unicodes As Variant
Dim i As Long

Const SomeHebrewHexCodes As String = "05D0,05E0,05D2,05E6"

For Each Unicodes In Split(SomeHebrewHexCodes, ",")
Range("A1").Offset(i, 0).Value = ChrW("&H" & Unicodes)
i = i + 1
Next

You can get the code for any letter on the worksheet with:

Public Function GetUnicodeValue(argText As Variant, _
WhichLetter As Long, _
Optional AsDecimal As Boolean = True) As
Variant

GetUnicodeValue = AscW(Mid(argText, WhichLetter, 1))
If AsDecimal = False Then GetUnicodeValue = Hex(GetUnicodeValue)

End Function

NickHK
 
I found the solution on another site. I quote " it's a Unicode display problem. If a user wants to type Arabic, French, and English in a non-Unicode Arabic application. The user should choose one of the Arabic system locales."

And the solution for Windows 7 and similar for other Windows is:
1. Go to Control Panel > "Clock, Region and Language" > "Region and Language"
2. Select Administrative tab > "Change system locale..." button and then select "Hebrew (Israel)".
 
Back
Top