diff --git a/vba_code_common.bas b/vba_code_common.bas index 595359e..337e86d 100644 --- a/vba_code_common.bas +++ b/vba_code_common.bas @@ -129,3 +129,25 @@ Sub WriteCSVFile(ByVal filePath As String, ByVal content As String) .Close End With End Sub + +Function ReadCSVFileWithUtf8(ByVal filePath As String) As Variant + If filePath = "" Then + ReadCSVFileWithUtf8 = Array() + Exit Function + End If + + Dim stream As Object + Dim textContent As String + + Set stream = CreateObject("ADODB.Stream") + With stream + .Type = 2 + .Charset = "utf-8" + .Open + .LoadFromFile filePath + textContent = .ReadText + .Close + End With + + ReadCSVFileWithUtf8 = Split(textContent, vbLf) +End Function diff --git a/vba_code_kotsu_master.bas b/vba_code_kotsu_master.bas index 121dc3f..daede6e 100644 --- a/vba_code_kotsu_master.bas +++ b/vba_code_kotsu_master.bas @@ -19,7 +19,7 @@ Sub Z1_ImportMasterDetailData() If filePath = "" Then Exit Sub ' Step 2: Read CSV - lines = ReadCSVFile(filePath) + lines = ReadCSVFileWithUtf8(filePath) ' Step 3: Validate column count If Not ValidateCSVColumnCount(lines, 7) Then Exit Sub