vba 显示 Unicode 字符:Excel 2010 与 Excel 2013
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14932086/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Displaying Unicode characters: Excel 2010 vs Excel 2013
提问by Larry K
I need to substitute plain ASCII for Unicode characters in an Excel spreadsheet. Eg convert St?le to Stale.
我需要用普通 ASCII 替换 Excel 电子表格中的 Unicode 字符。例如,将 St?le 转换为 Stale。
The following works fine in Excel 2013. But in Excel 2010, a "?" is displayed instead of the problematic character. Any ideas? Note that the non-Ascii characters are correctly detected in Excel 2010, but the characters aren't displayed.
以下在 Excel 2013 中工作正常。但在 Excel 2010 中,“?” 显示而不是有问题的字符。有任何想法吗?请注意,在 Excel 2010 中正确检测到非 Ascii 字符,但未显示这些字符。
char = Mid(val, i, 1)
char_code = AscW(char)
If char_code > 127 Then
MsgBox ("Problem with " & c.Address & " [" & char_code & "] " &
StrConv(ChrW(char_code), vbUnicode))
End If
I also tried just
我也试过
MsgBox ("Problem with " & char & " " & ChrW(char_code))
Again it worked with Excel 2013 but not Excel 2010.
它再次适用于 Excel 2013,但不适用于 Excel 2010。
回答by Larry K
More research reveals:
更多研究表明:
The MsgBox control for Excel 2010 does not support Unicode characters. The Excel 2013 MsgBox does.
Excel 2010 的 MsgBox 控件不支持 Unicode 字符。Excel 2013 MsgBox 可以。
The Unicode non-ASCII character works fine when the character is inserted into a worksheet cell. The problem is only when using MsgBox to display it. Good news is that the problem is fixed in Excel 2013. More on the subject.
当字符插入到工作表单元格时,Unicode 非 ASCII 字符工作正常。只有在使用 MsgBox 显示时才会出现问题。好消息是该问题已在 Excel 2013 中解决。有关该主题的更多信息。