使用VBA代码将excel表格批量转换格式csv

使用VBA代码,将excel表格Xlsx、xls格式批量转换为csv格式。

Sub SaveToCSVs()
    Dim fDir As String
    Dim wB As Workbook
    Dim wS As Worksheet
    Dim fPath As String
    Dim sPath As String
    fPath = "C:\Users\qiany\Desktop\文件\"
    sPath = "C:\Users\qiany\Desktop\csv保存位置\"
    fDir = Dir(fPath)
    Do While (fDir <> "")
        If Right(fDir, 4) = ".xls" Or Right(fDir, 5) = ".xlsx" Then
            On Error Resume Next
            Set wB = Workbooks.Open(fPath & fDir)
            'MsgBox (wB.Name)
            For Each wS In wB.Sheets
                wS.SaveAs sPath & wB.Name & ".csv", xlCSV
            Next wS
            wB.Close False
            Set wB = Nothing
        End If
        fDir = Dir
        On Error GoTo 0
    Loop
End Sub

 

Excel技巧

excel删除中文字符,保留英文和数字VBA公式

2020-11-26 18:29:58

Excel技巧

Excel公式对比速卖通无忧和E邮宝运费

2019-7-11 15:27:20

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索