I have a string containing unicode characters in VBA.
I want to display that string in a message box containing it.
However, instead of the string, the message box only contains a questionmark.
MCVE:
Dim s As String
s = ChrW(5123)
MsgBox s
I have a string containing unicode characters in VBA.
I want to display that string in a message box containing it.
However, instead of the string, the message box only contains a questionmark.
MCVE:
Dim s As String
s = ChrW(5123)
MsgBox s
MsgBox
is not compatible with non-ANSI unicode characters.We can display message boxes with the WinAPI
MessageBoxW
function, however, and that is .Let's declare that function, and then create a wrapper for it that's nearly identical to the VBA
MsgBox
function:This function is only compatible with Microsoft Access. However, for Excel you can swap
Application.hWndAccessApp
withApplication.hWnd
to make it work. For other VBA compatible applications, you'll have to find the appropriate way to get the hWnd.You can use it like
MsgBox
, as long as you don't use the context-dependent help functionality: