The following code works fine in Excel 2003 but returns the following error in Excel 2007:
Run time error '445'
Object does not support this action
CODE:
Sub List_Files()
Dim lCount As Long
Dim wbResults As Workbook
Dim wbCodeBook As Workbook
Set wbCodeBook = ThisWorkbook
With Application.FileSearch
.NewSearch
.LookIn = "C:\Departments\Inventory\"
.FileType = msoFileTypeAllFiles
.Filename = "20*"
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)
Application.StatusBar = Str(lCount) & " files found - Now working on " & ActiveWorkbook.FullName
rteval = MsgBox("Now working on " & ActiveWorkbook.FullName)
wbResults.Close SaveChanges:=True
Next lCount
End If
End With
End Sub
Run time error '445'
Object does not support this action
CODE:
Sub List_Files()
Dim lCount As Long
Dim wbResults As Workbook
Dim wbCodeBook As Workbook
Set wbCodeBook = ThisWorkbook
With Application.FileSearch
.NewSearch
.LookIn = "C:\Departments\Inventory\"
.FileType = msoFileTypeAllFiles
.Filename = "20*"
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)
Application.StatusBar = Str(lCount) & " files found - Now working on " & ActiveWorkbook.FullName
rteval = MsgBox("Now working on " & ActiveWorkbook.FullName)
wbResults.Close SaveChanges:=True
Next lCount
End If
End With
End Sub