<TABLE sizset="14" sizcache="6"><TBODY sizset="14" sizcache="6"><TR sizset="14" sizcache="6"><TD class=votecell>
</TD><TD class=postcell sizset="14" sizcache="6">I use the code as below.
Private Sub CommandButton1_Click()
Const File$ = "C:\CsvfileTest2.csv"
Dim Fso, MyFile
Set Fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = Fso.CreateTextFile(File, True)
MyFile.Close
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile File
.Position = 0
.Charset = "UTF-8"
.SaveToFile File, 2
.Close
End With
'Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set MyFile = FspenTextFile(File, 8, True, True)
' Just for the example:
myrange1 = 10
box = ""
For i = 1 To myrange1
box = ""
<CODE> For j = 1 To 10 </CODE>
<CODE> box = box & Sheet1.Cells(i, j) & ChrW(44)</CODE>
<CODE> Next j </CODE>
</PRE>MyFile.WriteLine box
Next i
MyFile.Close
End Sub
the file which I creat is not a realy csv. can anybody help me?
</TD></TR></TBODY></TABLE></P>
</TD><TD class=postcell sizset="14" sizcache="6">I use the code as below.
Private Sub CommandButton1_Click()
Const File$ = "C:\CsvfileTest2.csv"
Dim Fso, MyFile
Set Fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = Fso.CreateTextFile(File, True)
MyFile.Close
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile File
.Position = 0
.Charset = "UTF-8"
.SaveToFile File, 2
.Close
End With
'Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set MyFile = FspenTextFile(File, 8, True, True)
' Just for the example:
myrange1 = 10
box = ""
For i = 1 To myrange1
box = ""
<CODE> For j = 1 To 10 </CODE>
<CODE> box = box & Sheet1.Cells(i, j) & ChrW(44)</CODE>
<CODE> Next j </CODE>
</PRE>MyFile.WriteLine box
Next i
MyFile.Close
End Sub
the file which I creat is not a realy csv. can anybody help me?
</TD></TR></TBODY></TABLE></P>