在同一文件夹内新建A.xlsx
打开A.xlsx,右键sheet1,查看代码,将以下代码粘贴:
Sub xls2csv()
Application.DisplayAlerts = False
t = ActiveWorkbook.Name
mypath = ActiveWorkbook.Path & "\"
myfile = Dir(mypath & "*.xls")
Do Until Len(myfile) = 0
If myfile <> t Then
Workbooks.Open Filename:=mypath & myfile
ActiveWorkbook.SaveAs Filename:=mypath & Left(myfile, InStr(myfile, ".") - 1) & ".csv", FileFormat:=xlCSV
End If
If myfile <> t Then ActiveWorkbook.Close
myfile = Dir
Loop
Application.DisplayAlerts = True
End Sub
点击运行-运行子过程或窗体
返回开始文件夹,已转换成功。