https://blog.csdn.net/weixin_43046974/article/details/120876697
宏/VBA批量将文件夹下的csv文件转换成xlsx
Sub change_CSV_to_XLSX()
ChDir "C:\Users\Administrator\Desktop\新建文件夹"
Dim sDir As String
Dim result_dir As String
result_dir = "C:\Users\Administrator\Desktop\新建文件夹"
sDir = Dir(result_dir & "\*.csv")
While Len(sDir)
Workbooks.Open Filename:=result_dir & "\" & sDir
Dim temp As String
temp = Left(sDir, Len(sDir) - 4)
ActiveWorkbook.SaveAs Filename:=result_dir & "\" & temp & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close
sDir = Dir
Wend
End Sub
标签:xlsx,VBA,sDir,文件夹,result,csv,dir From: https://www.cnblogs.com/wendaozhe/p/16982279.html