Sub cons()
Dim myfile As String, myfolder As String, counter As Long
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'create a new workbook and rename it to store the name of the workbooks in the folder
'Workbooks.Add.SaveAs "C:\Users\skhur1\Desktop\Named workbook", FileFormat:=50
'storing folder path
myfolder = "C:\Users\skhur1\Desktop\New folder\"
'storing files path
myfile = Dir(myfolder & "*.xls*")
'loop to open the folder and loop through the files saved in it.
Do While Len(myfile) > 0
If LCase(Right(myfile, 4)) <> "xlsb" Then
'opening each file one by one
With Workbooks.Open(myfolder & myfile)
.SaveAs myfolder & Left(.Name, InStrRev(.Name, ".") - 1), FileFormat:=50
.Close
counter = counter + 1
End With
End If
myfile = Dir
Loop
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox counter & " files resaved. "
End Sub
Bookmarks