Hi All,
I'm trying o import a CSV file and splitting it up using "{" as seperator. The Data in the .csv file is already formatted as UTF-8. However, when importing it to my Excel workbook it returns to be w/o UTF-8.
Could somebody give me an example how I can encode it to UTF-8?
Private Sub CommandButtonImport_Click()
Dim fd As Office.FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Filters.Clear
.Title = "Select a CSV File"
.Filters.Add "CSV", "*.csv", 1
.AllowMultiSelect = False
Dim sFile As String
If .Show = True Then
sFile = .SelectedItems(1)
End If
End With
'Umlaute anpassen
'Import CSV from FileDialog
If sFile <> "" Then
Open sFile For Input As #1
row_number = 0
Do Until EOF(1)
Line Input #1, LineFromFile
LineItems = Split(LineFromFile, "{")
Application.Range("InputRange").Cells(row_number, 1).Value = LineItems(0)
Application.Range("InputRange").Cells(row_number, 2).Value = LineItems(1)
Application.Range("InputRange").Cells(row_number, 3).Value = LineItems(2)
Application.Range("InputRange").Cells(row_number, 4).Value = LineItems(3)
Application.Range("InputRange").Cells(row_number, 5).Value = LineItems(4)
Application.Range("InputRange").Cells(row_number, 6).Value = LineItems(5)
Application.Range("InputRange").Cells(row_number, 7).Value = LineItems(6)
row_number = row_number + 1
Loop
Close #1
End If
End Sub
|