MS Excel Vba Arabic unicode

北城余情 提交于 2021-02-18 19:42:38

问题


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

  1. Press win key or click on it
  2. Type region and click on it when windows finds it
  3. Choose administrative tab
  4. Under the language for non-Unicode programs you will find "change system locale" key
  5. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!