Search code examples
excelvbaexport-to-csvutfcjk

Write Chinese Characters And Alphabet in Cells Into .CSV


I'm trying to write data into a CSV file. The data contains both Chinese Characters and general text. My results look like this after exporting it into CSV file:

enter image description here

But it is supposed to look like this:

enter image description here

All the Chinese Characters, like "物料申请系统", "ADC培训", etc. are all turned into "?".

Here is my code:

Open Location For Output As #1
    For i = 2 To lastrow
        For j = 1 To LastCol
            If j = LastCol Then 'keep writing to same line
                TextLine = TextLine & Cells(i, j).Text  'read line into variable
            Else 'end the line
                TextLine = TextLine & Cells(i, j).Text & Deliminator
            End If
        Next j
            Print #1, TextLine
            TextLine = ""
    Next i
Close #1

Solution

  • Try something like:

     your_worksheet.SaveAs "your file path and name", xlUnicodeText
    

    You could also use the FileSystemObject

    I don't believe the VBA Open for Output : Print (or Write) support Unicode.