Sub ConvertToXLSX() 'Converts Excel files in a user-specified folder to the .xlsx format with macros removed Dim f As String, flPath As String Dim bStatus As Boolean flPath = Application.GetSaveAsFilename(FileFilter:="Excel files, (*.xls*); *.xlsx", _ Title:="Please pick any file in folder to be converted, then click 'Save'") If flPath = "False" Then Exit Sub flPath = Left(flPath, InStrRev(flPath, "\")) f = Dir(flPath & "*.xls*") bStatus = Application.DisplayStatusBar 'Remember if the status bar is being displayed Application.DisplayStatusBar = True Application.ScreenUpdating = False Application.EnableEvents = False 'Don't run event macros when workbooks open Application.DisplayAlerts = False 'Don't display alert messages On Error GoTo errhandler Do Until f = "" If Right(f, 1) <> "x" Then Application.StatusBar = "Now processing file: " & f With Workbooks.Open(f) .SaveAs flPath & Left(f, InStrRev(f, ".")) & "xlsx", FileFormat:=51 '.xlsx file format .Close SaveChanges:=False End With Kill flPath & f 'Delete the original workbook End If f = Dir Loop errhandler: Application.StatusBar = False 'Clear the status bar text Application.DisplayStatusBar = bStatus 'Restore the status bar display to its previous state Application.ScreenUpdating = True Application.EnableEvents = True 'Run event macros when workbooks open Application.DisplayAlerts = True 'Display alert messages End Sub
Gain unlimited access to on-demand training courses with an Experts Exchange subscription.Get Access
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.