我想将我的 excel 文件中的数据导出到保存在文件夹 S:\froyo\ics 中的 csv 中。我想以我的计算机配置文件名称命名 csv 文件。我目前使用下面的代码,但我没有正确命名部分。
子 csvfile()
Dim fs As Object, a As Object, i As Integer, s As String, t As String, l As String, mn As String
Set fs = CreateObject("Scripting.FileSystemObject")
sUser = Environ("username")
Set a = fs.CreateTextFile("S:\froyo\ics\sUser.csv", True)
For r = 1 To Range("A65536").End(xlUp).Row
s = ""
c = 1
While Not IsEmpty(Cells(r, c))
s = s & Cells(r, c) & ","
c = c + 1
Wend
a.writeline s 'write line
Next r
结束子