欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Excel宏:批量转化当前文件夹所有CSV2XLSX

程序员文章站 2022-05-16 09:29:12
...
Sub csv2xlsx()
    On Error Resume Next
    Application.ScreenUpdating = False
    fPath = ThisWorkbook.Path & "\"
    fName = Dir(fPath & "*.csv")
    Do While Len(fName)
        With Workbooks.Open(fPath & fName, ReadOnly:=True)
            .SaveAs fPath & Replace(fName, ".csv", ".xlsx"), IIf(Application.Version >= 12, xlWorkbookDefault, xlWorkbookNormal)
            .Close
        End With
        fName = Dir
    Loop
End Sub

 

相关标签: VBA