excel批量转csv表格,解除密码另存为xlsx

参考:

https://jingyan.baidu.com/article/380abd0a032e681d91192c74.html

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

接触密码另存为xlsx


Sub SaveToCSVs()

    Dim fDir As String

    Dim wB As Workbook

    Dim wS As Worksheet

    Dim fPath As String

    Dim sPath As String

    fPath = "D:\个人\解密码\2011年\"

    sPath = "D:\个人\2011年\"

    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)
            wB.SaveAs sPath & wB.Name & ".xlsx", xlOpenXMLWorkbook

            wB.Close False

            Set wB = Nothing

        End If

        fDir = Dir

        On Error GoTo 0

    Loop

End Sub

https://www.cnblogs.com/redufa/p/13686750.html
posted @ 2021-03-04 16:30  kuanleung  阅读(28)  评论(0)    收藏  举报  来源