0

I insert textbox to my Excel 2013 document and put some text

正体字/繁体字

with UTF-8 symbols In textbox its looks ok but when I trying to msgbox it with command

MsgBox ActiveSheet.Shapes("Textbox 1").TextFrame.Characters.Text

I get something like

???/???

So how to set UTF_8 charset to get normally this text in msgbox or into variable?

Dmitrij Holkin
  • 1,995
  • 3
  • 39
  • 86

2 Answers2

1

You can create something that looks like a MsgBox and functions like a MsgBox, but can better handle UniCode:

Public Declare Function MessageBoxU Lib "user32" Alias "MessageBoxW" _
                            (ByVal hwnd As Long, _
                             ByVal lpText As Long, _
                             ByVal lpCaption As Long, _
                             ByVal wType As Long) As Long
Sub MsgBoxSubstitute()
    Dim s As String
    s = ChrW(8451)
    MessageBoxU 0, StrPtr(s), StrPtr("MsgBox Substitute"), 0
End Sub

Using the Windows API. Note it has a nice built-in mechanism to dismiss the message.

Gary's Student
  • 95,722
  • 10
  • 59
  • 99
0

The only workaround is to create a form and display your message in a label. I think labels are UTF-8 enabled.

Amen Jlili
  • 1,884
  • 4
  • 28
  • 51