tabrizbalasi
New Member
- Joined
- Sep 14, 2014
- Messages
- 2
I am using the following vba code to import all txt files in the active directory into excel.
However my txt files are in UTF-8 character encoding. How can I import them using the above code but in UTF-8 code?
I tried to use this:
but without success. Your help is appreciated.
Could you please help me to modify this formula to import txt files in utf-8? thanks
Code:
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
However my txt files are in UTF-8 character encoding. How can I import them using the above code but in UTF-8 code?
I tried to use this:
Code:
With CreateObject("ADODB.Stream")
.Charset = "utf-8" 'Specify charset For the source text data.
End With
but without success. Your help is appreciated.
Could you please help me to modify this formula to import txt files in utf-8? thanks