我使用以下vba代码将活动目录中的所有 txt文件导入到Excel中。
Date YEAR SHARE-VALUE Cusip
0 2015-06-18 1 0.3293 APPL
1 2015-06-17 1 0.3528 GOOGL
2 2015-06-16 1 0.3507 LEN
3 2015-06-15 1 0.3581 TSD
但是我的txt文件采用UTF-8字符编码。如何使用上面的代码导入它们,但是使用UTF-8代码?
我试着用这个:
Sub ImportTXTfiles()
Dim Path As String
Path = Application.ActiveWorkbook.Path & "\"
Filename = Dir(Path & "*.txt")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy after:=ThisWorkbook.Sheets("Sheet1")
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub
但没有成功。感谢您的帮助。