1.csv转xls
ChDir "C:\Users\Administrator\Desktop\新建文件夹" '切换到文件夹,貌似可删除,后面都用的绝对路径
Dim sDir As String
Dim curdir As String
curdir = "C:\Users\Administrator\Desktop\新建文件夹"
sDir = Dir(curdir & "\*.csv")
While Len(sDir)
Workbooks.Open Filename:=curdir & "\" & sDir
Dim temp As String
temp = Left(sDir, Len(sDir) - 4)
ActiveWorkbook.SaveAs Filename:=curdir & "\" & temp & ".xls", _
FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close
sDir = Dir
Wend
2.csv转xlsx
ChDir "C:\Users\Administrator\Desktop\新建文件夹" '切换到文件夹,貌似可删除,后面都用的绝对路径
Dim sDir As String
Dim curdir As String
curdir = "C:\Users\Administrator\Desktop\新建文件夹"
sDir = Dir(curdir & "\*.csv")
While Len(sDir)
Workbooks.Open Filename:=curdir & "\" & sDir
Dim temp As String
temp = Left(sDir, Len(sDir) - 4)
ActiveWorkbook.SaveAs Filename:=curdir & "\" & temp & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close
sDir = Dir
Wend