文章目录

用VBA读取TXT文件到EXCEL

1
2
3
4
Dim objStream, strData
Set objStream = CreateObject("ADODB.Stream")
objStream.Charset = "utf-8"

‘ LINUX 换行符 objStream.LineSeparator = 10 默认是 -1 回车换行符
objStream.Open objStream.LoadFromFile ("C:\Users\Administrator\Desktop\test.txt") rowNo = 1 Do While Not (objStream.EOS) Worksheets("Sheet1").Cells(rowNo, 1).Value = objStream.ReadText(-2) '每次读一行 rowNo = rowNo + 1 Loop ' 关闭 objStream.Close Set objStream = Nothing
文章目录