问题
In VBA Excel to print " & Chr(34) & "
is used to define "
. I have searched and it said 34th character is "
, as per this website.
In same way for 👍 Thumbs Up Sign the code is
👍 👍
I have tried:
" & Chr(#128077) & "
" & Chr(128077) & "
" & Chr(#x1f44d) & "
" & Chr(x1f44d) & "
But it says error as a Syntax error or Expecting ) or Invalid Argument
Can anyone suggest me the solution
回答1:
In Excel, characters are stored using Unicode UTF-16
. "Thumbs up" corresponds to the Unicode character U+1F44D, encoded as follows:
in UTF-16 (hex) : 0xD83D 0xDC4D (d83ddc4d)
in UTF-16 (decimal) : 55357 , 56397
All those characters which are not the classic latin characters (ASCII) are to be handled with chrW
and ascW
.
So, in your case
ChrW(55357) & ChrW(56397)
or
ChrW(&HD83D) & ChrW(&HDC4D)
would produce thumbs up. Also note that you won't get that in the VBA IDE. You will have to put it in a worksheet to see it.
Clarification
' Puts a thumbs up symbol in A1
ActiveSheet.Range("A1").Value = ChrW(55357) & ChrW(56397)
' Will not produce a thumbs up symbol, since VBA can't handle it
Debug.Print ChrW(55357) & ChrW(56397)
' Will not produce a thumbs up symbol, since VBA can't handle it
MsgBox ChrW(55357) & ChrW(56397)
HTML
If you want the thumbs up to be in HTML, then do like this:
HtmlString = "<p>something something 👍</p>"
Print #1, HtmlString ' <-- replace with your output method
(👍
or 👍
)
来源:https://stackoverflow.com/questions/55195005/can-anyone-explain-how-to-insert-emojis-to-vba-excel