How do I export csv with unicode by VBA

JoyShih

New Member
Joined
Mar 10, 2011
Messages
2
Hi
I tried to find as many as reference on the web, to find out how to export unicode csv.
But unfortunatly I still got wrong data when original file with Japanese words.
How shall I do? Many thanks.

My current code is something like

Dim arr1() As Variant
Dim Delimiter As String
Dim Filename As String
Dim R As Long
Dim Rng As Range
Dim Text As String
Dim Wks As Worksheet
Dim C As Long

Delimiter = StrConv(",", vbUnicode)
Set Wks = Worksheets(1)
Set Rng = Wks.UsedRange

Filename = ActiveWorkbook.Path & "\" & Wks.Name & ".csv"

ReDim arr1(1 To Rng.Rows.Count)

Open Filename For Output As #1
For R = 1 To Rng.Rows.Count
arr1 = WorksheetFunction.Index(Rng.Rows(R).Cells.Value, 1, 0)
Text = Join(arr1, Delimiter)
'Text = StrConv(Text, vbUnicode)
Print #1, Text

Next R
Close #1
MsgBox "OK"
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi for the same above code how can i get the file generated to be unicode ... i mean the code should be able to write the existing file to a unicode text file
 
Upvote 0
I believe the code in post #2 should save any worksheet in unicode format.

This site has a lot of information about Excel "Save As" method.

This site talks about using google spreadsheet for unicode conversion.
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,814
Members
452,945
Latest member
Bib195

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top