首页 > 技术文章 > Excel批量转化CSV (转载)

redufa 2020-09-17 16:28 原文

链接:https://zhuanlan.zhihu.com/p/52458010

 

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

 

推荐阅读