从Excel工作表中读取中文字符? (总是返回“????”)

时间:2012-03-09 10:52:36

标签: excel vba non-ascii-characters

如何从Excel单元格中读取中文字符并将其写入文件?当我按

取值时
Worksheets(ActiveCell.Worksheet.Name).Cells(3, columnNumbers(0)).value

它总是返回“????????”

2 个答案:

答案 0 :(得分:3)

Dim fileStream, FilePath As String    

'Full properties file path
propFilePath = "C:\file.properties"

'Create Stream object
Set fileStream = CreateObject("ADODB.Stream")

'Specify stream type – we want To save text/string data.
fileStream.Type = 2

'Specify charset For the source text data.
fileStream.Charset = "utf-8"

'Open the stream And write binary data To the object
fileStream.Open
fileStream.writetext "write something here"

'Save binary data To disk
fileStream.SaveToFile FilePath, 2
fileStream.Close

答案 1 :(得分:1)

  1. 这可能是csv文件
  2. 使用文本编辑器打开,以UTF8或UNICODE格式保存