Write header separately to avoid encoding issue
This commit is contained in:
@@ -414,12 +414,21 @@ Sub ExportMasterDetailData()
|
||||
csvContent = Left(csvContent, Len(csvContent) - 1)
|
||||
Loop
|
||||
|
||||
' Write file
|
||||
' Write header using native VBA (no charset conversion)
|
||||
Dim f As Long
|
||||
f = FreeFile
|
||||
Open savePath For Output As #f
|
||||
Print #f, CSV_HEADER;
|
||||
Close #f
|
||||
|
||||
' Append data using ADODB.Stream with shift_jis
|
||||
Dim stream As Object
|
||||
Set stream = CreateObject("ADODB.Stream")
|
||||
stream.Type = 2
|
||||
stream.Charset = "shift_jis"
|
||||
stream.Open
|
||||
stream.LoadFromFile savePath
|
||||
stream.Position = stream.Size
|
||||
stream.WriteText csvContent, 1
|
||||
stream.SaveToFile savePath, 2
|
||||
stream.Close
|
||||
|
||||
Reference in New Issue
Block a user