Special characters (letters čćžšđ) in Excel 2013 V

2019-07-22 01:26发布

I made a program in Excel 2010 VBA that contains letters like ć č š...

Msgbox("Čiča gliša") works.

Looks like Excel 2013 supports those letters in cells and formulas, but not in VBA.

VBA replaces them with some symbols which aren't even on the keyboard.

I get errors executing the code.

I believe it's something to do with language settings.

4条回答
戒情不戒烟
2楼-- · 2019-07-22 01:57

Problem is in windows regional settings: Region/Administrative/Language for non-unicode programs, which must be set to language that can handle your special characters.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-07-22 01:58

VBA is ANSI. Ps in it's interactions with Windows. It's UTF16 internaly and COM is also UTF 16. But it's file format is also ANSI so typing wierd strings are not likely to work (because they can't be saved as is).

So character conversion happen automatically with a million rules controlling it (mostly undocumented in an accessible fashion).

If in trouble assign to a byte array. Maybe you bneed toread from unicode file to bypass form's ANSI.

Yourstring() = "blah blah"

VB treats byte arrays as strings if passed to string functions.

查看更多
beautiful°
4楼-- · 2019-07-22 02:11

You can write manually the accents in every piece of code they appear, and you can use the "find & replace" to do it faster. If you have something like:

MsgBox "Código único"

Then you can find and replace:

[ó] to [" & Chr(243) & "]

[ú] to [" & Chr(250) & "]

And so on...

And you will get:

MsgBox "C" & Chr(243) & "digo " & Chr(250) & "nico"

If you don't know the code for each accented letter, then you can use excel with the function "CODE" (Function Char does the opposite)

Also, you could use a list from the internet like this one:

ASCII Code - The extended ASCII table

I just had the same problem and did this procedure. Worked fine using Visual Studio Code and very fast.

查看更多
乱世女痞
5楼-- · 2019-07-22 02:12

As BambiLongGone stated, weird string are not likely to work. I would say your best shot is looking at this article. There 's a tool called Unicode to VBA that you can use to convert all your string in your application. For example :

Čiča gliša

will be converted to

ChrW$(&H10C) & "i" & ChrW$(&H10D) & "a gli" & ChrW$(&H161) & "a"
查看更多
登录 后发表回答