批次转换Excel格式, 由xls转为xlsx

**批次转换Excel存档格式, 由xls转为xlsx

xls格式是Excel2003及以前的Excel版本, 该格式数据只支援到256列和65536行, 且xls格式与xlsx格式档案大小也有差异, 档案体积的差异最小有2倍之多, 最大有10倍之多

Sub ConvertToXlsx()
    Dim strPath As String
    Dim strFile As String
    Dim xWbk As Workbook
    Dim xSFD, xRFD As FileDialog
    Dim xSPath As String
    Dim xRPath As String
    'xls 存放的资料夹
    Set xSFD = Application.FileDialog(msoFileDialogFolderPicker)
    With xSFD
        .Title = "Please select the folder contains the xls files:"
        .InitialFileName = "C:\"
    End With
    If xSFD.Show <> -1 Then Exit Sub
    xSPath = xSFD.SelectedItems.Item(1)
    '转为 xlsx 後要存放的资料夹
    Set xRFD = Application.FileDialog(msoFileDialogFolderPicker)
    With xRFD
        .Title = "Please select a folder for outputting the new files:"
        .InitialFileName = "C:\"
    End With
    If xRFD.Show <> -1 Then Exit Sub
    xRPath = xRFD.SelectedItems.Item(1) & "\"
    
    strPath = xSPath & "\"
    strFile = Dir(strPath & "*.xls")
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    '开启xls 另存为xlsx
    Do While strFile <> ""
        If Right(strFile, 3) = "xls" Then
            Set xWbk = Workbooks.Open(Filename:=strPath & strFile)
            xWbk.SaveAs Filename:=xRPath & strFile & "x", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
            xWbk.Close SaveChanges:=False
        End If
        strFile = Dir
    Loop
    
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub

<<:  蓝底白字错误讯息

>>:  费根检查( Fagan inspection)

Material UI in React [Day9] Inputs (Radio) 单选 & (Switch) 开关

Radio 当用户需要查看所有可用选项时使用单选按钮,如果可用选项可以折叠,请考虑使用下拉菜单(Se...

Day20-94. Binary Tree Inorder Traversal

94. Binary Tree Inorder Traversal(Easy) Given the ...

[15] 建立 class 创建实例的继承

考量到要建立各种 class 所以统一建立一个 class 给所有人继承 可以直接跳过,但注意之後有...

Android Studio 上传GitHub

GitHub 官方说明 we announced our intent to require the...

部落格怎麽进行搜寻引擎优化?

一、前言 很多人可能会觉得 SEO 优化是种单一的技巧,有一套可依循的 SOP,只要学会就可以操作...