• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7814
  • Last Modified:

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 ?


<<question wording edited to improve readability--byundt, Microsoft Excel Topic Advisor>>
  • 2
1 Solution
RartemassAuthor, martial arts coach, IT ConsultantCommented:
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.
AXISHKAuthor Commented:
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 ?

I attach the tool. At the bottom of the code sheet I have added the procedure 'MessageText' and the sub 'TestMsgBox' to test it.
On my laptop I don't get the Chinese characters displayed in MsgBoxes because I have English as default language. I believe, if you run Chinese as default language you will get the proper display. In fact, it may be worth a try to see if you can enter Chinese characters in VB if Chinese is your default (as compared to a true Chinese OS with English as second language where I know it is possible). I know for a fact that Chinese as default language in an English version of Windows handles Chinese characters in MsgBoxes differently than where English is default and Chinese is the second language on the same platform.
You may like to read up at this link where they have another converter. Perhaps they found something I don't know. I tried their suggestion to create a MsgBox prompt directly from ChrW() characters but didn't have any luck with that.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now