martinctc
9/11/2017 - 8:41 PM

Bulk Convert XLS to XLSX

Bulk convert XLS to XLSX. Code not my own

Sub ConvertToXlsx()
On Error Resume Next
    Dim strPath As String
    Dim strFile As String
    Dim wbk As Workbook
    ' Path must end in trailing backslash
    strPath = "C:\Users\Martin\Desktop\Test\"
    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