问题
I have a text file and a macro enabled excel file. the excel file gets (using vba) the string (arabic text) from the text file per line then put it on the sheet1 cells. The problem is the string is not properly displayed. It is displayed in random Japanese characters. (My windows locale is Japan).
Here is my code:
Open FilePath For Inputs As #1
Do Until EOF(1)
Line Input #1, textline
ActiveWorkbook.sheets(1).Cell(1,1).Value = textline
'MsgBox(textline)
Loop
Close#1
Question: How can I get the string(arabic text) to be still arabic when pasted in the excel file?
回答1:
I found the solution after searching in many posts. Please follow the followings
- Press win key or click on it
- Type region and click on it when windows finds it
- Choose administrative tab
- Under the language for non-Unicode programs you will find "change system locale" key
- A restart would be required
回答2:
Sorry, feels like it's been quite a time since the question was raised.
But still I'd like to propose a solution:
Using unicode
encoding
to represent different language: Sheet1.Cells(2, 1) = ChrW(&H3091)
, which is standing for character ゑ
.
回答3:
Found a way around using Ms Excel. Under Data tab > Import Data from text. Dont forget to set the encoding to UTF-8
Voila! Magic!
来源:https://stackoverflow.com/questions/44246275/ms-excel-vba-arabic-unicode