ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   set unicode in macro (https://www.excelbanter.com/excel-programming/437870-set-unicode-macro.html)

GadyC

set unicode in macro
 
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

Harald Staff[_3_]

set unicode in macro
 
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


"GadyC" skrev i melding
...
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




Gary''s Student

set unicode in macro
 
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.




--
Gary''s Student - gsnu200909


"GadyC" wrote:

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



All times are GMT +1. The time now is 11:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com