I created a script in order to import csv file. The script works but I would like import this file with utf-8 encoding.
Could someone help me with some of these problems?
This is my script:
Sub ImportCSV()
Dim dialogBox As FileDialog
Dim selectedFile As String
Set dialogBox = Application.FileDialog(msoFileDialogFilePicker)
With dialogBox
.Filters.Add "CSV", "*.CSV", 1
.AllowMultiSelect = False
If .Show = True Then
selectedFile = .SelectedItems(1)
End If
Debug.Print selectedFile
End With
If selectedFile <> "" Then
Open selectedFile For Input As #1
Dim rowNumber As Long
Dim lineFromFile As String
Dim lineItems As Variant
Dim iteration As Integer
rowNumber = 1
Do Until EOF(1)
Line Input #1, lineFromFile
lineItems = Split(lineFromFile, ";")
For iteration = 0 To 14
Range("ImportRange").Cells(rowNumber, iteration + 1) = lineItems(iteration)
Next
rowNumber = rowNumber + 1
Loop
Close #1
End If
End Sub
I tried and the script works but the encoding is wrong, I would like import my file with utf-8 encoding.
VBA
Openmethod doesn't support UTF8.ADODB.Streamcan handle UTF8 encoding file.