Sub fdfdfdf()
Dim strDirPath, strMaskSearch, strFileName As String
strDirPath = "C:/Path/"
strMaskSearch = "*.xlsx*"
strFileName = Dir(strDirPath & strMaskSearch)
Call FileConversion(strFileName)
End Sub
Sub FileConversion(strFileName As String)
Dim wBook As Workbook
Dim sFldr As String, sNewName As String, sFormat As String
sFldr = ThisWorkbook.Path & "\" & "Conversion" & "\"
If Dir(sFldr, vbDirectory) = "" Then MkDir sFldr
sNewName = Mid$(strFileName, InStrRev(strFileName, "\") + 1)
sNewName = Left$(sNewName, InStrRev(sNewName, ".") - 1)
If Right(strFileName, 1) = "s" Or Right(strFileName, 1) = "x" Then
sNewName = sNewName & ".xlsm": sFormat = xlOpenXMLWorkbookMacroEnabled
Else
sNewName = sNewName & ".xls": sFormat = xlExcel8
End If
With Application: .ScreenUpdating = False: .DisplayAlerts = False: End With
Set wBook = Workbooks.Open(Filename:=strFileName)
With wBook
.SaveAs Filename:=sFldr & sNewName, FileFormat:=sFormat, CreateBackup:=False
.Close
End With
Set wBook = Nothing
With Application: .ScreenUpdating = True: .DisplayAlerts = True: End With
End Su