set unicode in macro

  • Thread starter Thread starter GadyC
  • Start date Start date
G

GadyC

I wrote a macro -> xla.
it returns manipulated and translated strings.
after passing to win7 i get the output in wrong language code, probably
unicode problem.

how can i assign a unoicode string into a varialble?

thanks in advance
 
Here is one way:

Sub test()
Dim S1 As String
Dim S2() As Byte
Dim L As Long

S1 = "Hello World"
'to unicode:
S2 = StrConv(S1, vbUnicode)

' byte array in the immedate window:
For L = LBound(S2) To UBound(S2)
Debug.Print L, S2(L), Chr(S2(L))
Next

'convert back:
S1 = StrConv(S2, vbFromUnicode)
MsgBox S1
End Sub

HTH. Best wishes Harald
 
Use Chr(). For example:

Sub dural()
ActiveCell.Font.Name = "Arial Unicode MS"
ActiveCell.Value = ChrW(8457)
End Sub

will put a degrees Fahrenheit symbol in a cell.
 
Back
Top