I have Windows9 with Excel 2010. I need a function to replace the Application.Filesearch Function. Some suggestions would be appreciated.
I have an example of some abbreviated code.
I have an example of some abbreviated code.
Code:
Sub Openallworkbooks()
'
' Openallwkbooks1 Macro
' Macro recorded 3/31/2009
'
Dim lCount As Long
Dim wbResults As Workbook
Dim wbCodeBook As Workbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
On Error Resume Next
Set wbCodeBook = ThisWorkbook
With Application.FileSearch
.NewSearch
'Change path to suit
.LookIn = "C:\Data\Daily_A"
.FileType = msoFileTypeExcelWorkbooks
.Filename = "ETF*.xls"
If .Execute > 0 Then 'Workbooks in folder
For lCount = 1 To .FoundFiles.Count 'Loop through all.
'Open Workbook x and Set a Workbook variable to it
Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)
'ActiveWindow.WindowState = xlMinimized
'DO YOUR CODE HERE
wbResults.Close SaveChanges:=True
Next lCount
End If
End With
On Error GoTo 0
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub