none
Only VBA does not recognize non-English characters RRS feed

  • Question

  • Hello guys,

    I have a new laptop with Windows 8.1 bought in the USA and I'm having a difficulties with Excel VBA (Office 365 University-64x bought in the Czech Republic - Central Europe). The VBA does not recognize non-English characters (particularly "ř" and "ů") which causes me problem when running some codes that I wrote earlier on my previous laptop (Windows 7, bought in the Czech Republic with the same Office). 
    The problem with non-English characters has occurred only in VBA so far, otherwise I can use these characters normally in Excel cells, Word... I tried to install both English and Czech version of the Office with no change, I also installed Czech proofreading tools and set everything to Czech in the Office. The location and language preferences in the Windows are also set up to Czech. And it is not a problem of a font. I also mentioned that when I tried to look up these characters, using Ctrl+F, it changes original ř to r after a search and again this is only an issue of the VBA.   

    Thank you very much for any help.
    Tom

    Friday, January 9, 2015 7:22 AM

All replies

  • Hi Tom,

    VBA for Excel can only recognize ASCII code from 0 to 255, if you use other special characters like "ř" or "ů", it will returns 63(?) to you. To use this kind of characters, you have to utilize ChrW function to parse a decemal to the character.

    http://msdn.microsoft.com/en-us/library/ee177465.aspx

    for example, the hex code and dec code for these two characters are as below:

      Hex   Dec
    ř 159   345
    ů 016F  367

    So to get these two characters in VBA, you could code as below:

    ChrW(&H159) or ChrW(345)
    ChrW(&H16F) or ChrW(367)

    You can get the hex code of the character by searching in the system character map(in the Win8.1 start view, search "character map"), then convert the hex code to decimal code by yourself.

    Range("A1").Value = ChrW(&H159) & ChrW(&H16F)
    Range("A1").Value = ChrW(345) & ChrW(367)


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 12, 2015 6:50 AM
    Moderator
  • Hello there,

    I see your point but you're not right. If it was so that VBA always uses ASCII, how would it be possible that the same code runs on laptops that were bought in the Czech Republic? I've just tried it today on almost the same laptop as I have (my bought in US and the other one in the Czech Republic) and the code that does not run in my VBA worked perfectly on the other laptop. 
    This leads me a point that something is wrong with my coding and hopefully there is a way to change the coding.

    Monday, January 12, 2015 8:17 PM
  • Hi Tom,

    Could you please post your VBA code here?


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 20, 2015 1:51 AM
    Moderator