Sub ConvertToXlsx()
Dim fso As Object
Dim fld As Object
Dim strPath As String
Set fso = CreateObject("Scripting.FileSystemObject")
' Specify the folder
strPath = "d:\Test"
Set fld = fso.GetFolder(strPath)
Call ProcessFolder(fld)
End Sub
Sub ProcessFolder(fld As Object)
Dim sfl As Object
Dim fil As Object
Dim wbk As Workbook
' Loop through the files
For Each fil In fld.Files
If Right(fil.Name, 3) = "xls" Then
Set wbk = Workbooks.Open(fil)
If wbk.HasVBProject Then
wbk.SaveAs fil & "m", 52
Else
wbk.SaveAs fil & "x", 51
End If
wbk.Close False
End If
Next
' Loop through the subfolders
For Each sfl In fld.SubFolders
' Call ProcessFolder recursively
Call ProcessFolder(sfl)
Next
End Sub
Dim fso As Object
Dim fld As Object
Dim strPath As String
Set fso = CreateObject("Scripting.FileSystemObject")
' Specify the folder
strPath = "d:\Test"
Set fld = fso.GetFolder(strPath)
Call ProcessFolder(fld)
End Sub
Sub ProcessFolder(fld As Object)
Dim sfl As Object
Dim fil As Object
Dim wbk As Workbook
' Loop through the files
For Each fil In fld.Files
If Right(fil.Name, 3) = "xls" Then
Set wbk = Workbooks.Open(fil)
If wbk.HasVBProject Then
wbk.SaveAs fil & "m", 52
Else
wbk.SaveAs fil & "x", 51
End If
wbk.Close False
End If
Next
' Loop through the subfolders
For Each sfl In fld.SubFolders
' Call ProcessFolder recursively
Call ProcessFolder(sfl)
Next
End Sub