Link to home
Start Free TrialLog in
Avatar of AXISHK
AXISHK

asked on

Chinese characters in Excel VBA

I'm working on a Window 7 English platform with English and Chinese language installed on Office.

The Chinese characters are displayed properly under Excel content. However, I cannot use the Chinese characters under Excel VBA. Here, any Chinese characters (high code) in the code won't be displayed.

Is there a way to allow Excel VBA to read other Asian characters ?

Tks

<<question wording edited to improve readability--byundt, Microsoft Excel Topic Advisor>>
VBA-Chinese-chars.png
Avatar of Rartemass
Rartemass
Flag of Australia image

VBA uses Unicode for displaying text. Certain Chinese characters were left out of Unicode because they were rarely used (such as for place names or form part of personal names). The characters you want to display may be one of those.
The system is showing some characters but not others which leads me to think the above may be the case.
What are the characters you are trying to display?
You need a Chinese version of Windows in order to have the VB editor display Chinese characters. You can create Chinese texts, however, by spelling them out in Unicode. that is tedious. i have a converter somewhere which takes a string of Chinese characters entered in an Excel worksheet and writes the Unicode (simplifed) characters in the adjacent column from where they can be copied into the VBE. If you are interested, I can post the tool after I get back home. (I'm on the road today and tomorrow.)
Seeing that you have to enter the Chinese strings into Excel anyway, the better way to work around the problem is to have the Code directly access the cells in the worksheet where you store the strings. For this purpose you can create a dedicated worksheet with the Visible property set to xlVeryHidden. In practise, you create a little procedure that returns the desired string based upon a row number. Your code then looks like MsgBox MsgString(1). You can add the English translation as a remark in the code or have it in column B of the very hidden worksheet.
Once I had all of this figured out I didn't miss Chinese characters in VBE any more. Instead, I toyed with having traditional characters in column B (simplified in column A and English in column C) so that I could choose which language or character set to display just by adding one more argument to the MsgString call.
Avatar of AXISHK
AXISHK

ASKER

Tks, I want to test the tool.

Actually, I have put the Chinese chars on Excel, extract it on the vb and then show it with msgbox. However, it can't display properly. Can you also upload a simple excel to show how it works.

In addition, I have grab the Excel Chinese tab name and can't display it properly in VBA. Will there be any solution for this ?

Tks
ASKER CERTIFIED SOLUTION
Avatar of Faustulus
Faustulus
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial