Try this macro. Change "MyFolder" to the actual path. To
use, open up a new workbook, press ALT+F11, go to Insert
Module, and paste in the code. Press ALT+Q, go to Tools
Macro > Macros and run it.
Sub ChangeXLS()
'Constructive criticism from VBA programmers appreciated
Dim MyFolder As String
Dim NewName As String
Dim OldName As String
Dim patharray As Variant
MyFolder = "C:\Program Files\ztest"
Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = MyFolder
.SearchSubFolders = False
.Filename = "*.txt"
.FileType = msoFileTypeAllFiles
Application.DisplayAlerts = False
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
patharray = Split(.FoundFiles(i), "\")
OldName = patharray(UBound(patharray))
NewName = Application.WorksheetFunction. _
Substitute(OldName, ".txt", ".xls")
Workbooks.Open Filename:=MyFolder _
& "\" & OldName
With ActiveWorkbook
.SaveAs Filename:=MyFolder & "\" & NewName
.Close
End With
Next
Else
MsgBox "There were no files found."
Exit Sub
End If
Application.DisplayAlerts = True
End With
Application.ScreenUpdating = True
End Sub