Hi
I am using Kill "[folder directory]" & "*.xls" to delete all the .xls type file in the folder but the code also delete file type .xlsx and .xlsm
Below are my code.
Please help. Thank you.
Sub ConvertXlsToXlsx()
Application.ScreenUpdating = False
Dim strPath As String
Dim strFile As String
Dim wbk As Workbook
' Path must end in trailing backslash
strPath = Range("Convert_Location") & "\"
strFile = Dir(strPath & "*.xls")
Do While strFile <> ""
If LCase(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
On Error Resume Next
Kill strPath & "*.xls"
On Error GoTo 0
MsgBox "This VBApp has completed its task." & vbNewLine & vbNewLine & "Please find the converted file(s) in the same folder."
End Sub
Bookmarks