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

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/VBS)