VBA display foreign character code

nd0911

Board Regular
Joined
Jan 1, 2014
Messages
166
Hello,

I'm trying to use foreign language (Hebrew) characters in VBA Msgbox.

I know that if I want to use foreign language characters I need to configure in Windows, the "non unicode programs" (in the control panel>Region>Administrative), but I want to achieve this without configure this Windows setting.

I tried to concatenate a few of chr/chrW functions to create a sentence and the prompt it as a message box but I get a gibberish text or a ????? text.

Is it possible to do it without changing the windows setting ?

here is a Hebrew text if you want to test it

VBA Code:
Sub Test
Msgbox "ניסיון"
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi, you could consider creating a userform with a textbox to display the message. You could easily make the userform and textbox look like a standard message box.
 
Upvote 0
Actually, this could be a nice idea, the thing is I want to do it with a userform that I will create it "On the fly", so I will not need to manage a Userform (I will create a generic module for my messages that I will take with me for every new project I will create).

The new quastion is: is it possible to create a userform on the fly, that not actualy exists when I finish with him ?
 
Upvote 0
The new quastion is: is it possible to create a userform on the fly, that not actualy exists when I finish with him ?

You can, and I'm sure you'll get lots of hits with an internet search. But personally, I don't think it's a good idea, what's wrong with created the form at design time?
 
Upvote 0
I know that if I want to use foreign language characters I need to configure in Windows, the "non unicode programs" (in the control panel>Region>Administrative), but I want to achieve this without configure this Windows setting.
[/CODE]
May I ask why you don't want to change system locale? I don't see any downside of doing it.
 
Upvote 0
You can, and I'm sure you'll get lots of hits with an internet search. But personally, I don't think it's a good idea, what's wrong with created the form at design time?
unfortunately I didnt find nothing on how to create a UserFrom at run time, I guess its impossible.

Thank you !
 
Upvote 0
May I ask why you don't want to change system locale? I don't see any downside of doing it.
I need to distribute to lots of users and some users have un-cofigured system location and thay dont understand english so I cant prompt them an english message on how to setup system location
 
Upvote 0
I'm trying to use foreign language (Hebrew) characters in VBA Msgbox.
You can do it with the MessageBoxW API function, called from a supporting function to mimic VBA MsgBox, like this:
VBA Code:
#If VBA7 Then
    Private Declare PtrSafe Function MessageBoxW Lib "user32" (ByVal hWnd As LongPtr, ByVal lpText As LongPtr, ByVal lpCaption As LongPtr, ByVal uType As Long) As Long
#Else
    Private Declare Function MessageBoxW Lib "user32" (ByVal hWnd As Long, ByVal lpText As Long, ByVal lpCaption As Long, ByVal uType As Long) As Long
#End If


Public Sub Test()
    MsgBoxW Range("A1").Value
End Sub


Public Function MsgBoxW(Prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional Title As String = "Microsoft Excel") As VbMsgBoxResult
    Prompt = Prompt & vbNullChar 'Add null terminators
    Title = Title & vbNullChar
    MsgBoxW = MessageBoxW(Application.hWnd, StrPtr(Prompt), StrPtr(Title), Buttons)
End Function
 
Upvote 0

Forum statistics

Threads
1,214,534
Messages
6,120,080
Members
448,943
Latest member
sharmarick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top