A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
This should work
Sub ConvertToXlsx()
Dim strPath As String
Dim strFile As String
Dim wbk As Workbook
' Path must end in trailing backslash
strPath = "C:\Test"
strFile = Dir(strPath & "*.xls")
Do While strFile <> ""
If Right(strFile, 3) = "xls" Then
Set wbk = Workbooks.Open(Filename:=strPath & strFile)
If wbk.HasVBProject Then
wbk.SaveAs Filename:=strPath & strFile & "m", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled
Else
wbk.SaveAs Filename:=strPath & strFile & "x", _
FileFormat:=xlOpenXMLWorkbook
End If
wbk.Close SaveChanges:=False
End If
strFile = Dir
Loop
End Sub