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

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)的批量操作)