With Application.FileSearch
.NewSearch
.FileType = msoFileTypeExcelWorkbooks
'.LookIn = "C:\Data"
.LookIn = UserForm1.txtLocation.Text
'.FileTypes
.SearchSubFolders = True
.Execute SortBy:=msoSortByFileType
If .FoundFiles.Count Then
UserForm1.Label4.Caption = .FoundFiles.Count
UserForm1.Repaint
For lFile = 1 To .FoundFiles.Count
On Error GoTo myerrhand
If UCase(Right(.FoundFiles(lFile), 3)) = "XLS" Then
Workbooks.Open Filename:=.FoundFiles(lFile), UpdateLinks:=0
xbook = ActiveWorkbook.Name
If UCase(xbook) <> "STDRPT1.XLS" Then
Application.StatusBar = "Now working on " &
ActiveWorkbook.FullName
'Here is the line that calls the macro below, passing the
workbook to it
DoChanges
ActiveWorkbook.Save
Application.DisplayAlerts = False
Windows(xbook).Close
End If
End If
myerrhand:
Windows(ActiveWorkbook.Name).Activate
Next lFile
End If
End With