美文网首页生产力
excel文件(.xls,.xlsx)的批量操作

excel文件(.xls,.xlsx)的批量操作

作者: 函数啊 | 来源:发表于2017-05-12 21:54 被阅读290次

xls批量转换为xlsx

vb代码

Sub ConvertToXlsx()
    Dim strPath As String
    Dim strFile As String
    Dim wbk As Workbook
    ' 路径请以反斜杠结尾
    strPath = "C:\xls2xlsx\"
    strFile = Dir(strPath & "*.xls")
    Do While strFile <> ""
        If Right(strFile, 3) = "xls" Then
            Set wbk = Workbooks.Open(Filename:=strPath & strFile)
            wbk.SaveAs Filename:=strPath & strFile & "x", _
                FileFormat:=xlOpenXMLWorkbook
            wbk.Close SaveChanges:=False
        End If
        strFile = Dir
    Loop
End Sub

注意:.xlsx 不在存储宏,所以将xls转为xlsx后会导致原工作簿中的宏丢失
来源

xls,xlsx批量转换为csv

http://cwestblog.com/2011/05/05/excel-batch-convert-xls-to-csv/

相关文章

网友评论

    本文标题:excel文件(.xls,.xlsx)的批量操作

    本文链接:https://www.haomeiwen.com/subject/gcutxxtx.html