|
楼主 |
发表于 2023-3-11 10:05
|
显示全部楼层
Private Sub CommandButton1_Click()
Const File$ = "C:\Users\Administrator\Desktop\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 = Fso.OpenTextFile(File, 8, True, True)
' Just for the example:
myrange1 = 50
box = ""
For i = 1 To myrange1
box = ""
For j = 1 To 11
box = box & Sheet1.Cells(i, j) & ChrW(44)
Next j
MyFile.WriteLine box
Next i
MyFile.Close
MsgBox "success"
End Sub
--------
CsvfileTest2.csv文件名改为SL加上表格中第三列+编号001 |
|