This function has worked for me in all Office applications until now, when I am trying to use Access 2007 and Windows 7.
I'm sending in the correct parameters but it's reporting
You entered an expression that has an invalid reference to the property FileSearch.
I can't figure out why, any help appreciated.
Code:
Function gFindFiles(findWhere, findWhat, Optional DoSubFolders As Boolean = True) As Variant
Dim aFiles() As Variant
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = findWhere
.SearchSubFolders = DoSubFolders
.MatchAllWordForms = False
.MatchTextExactly = False
.FileType = 1 'msoFileTypeAllFiles
.Filename = findWhat
.MatchTextExactly = True
.Execute 'msoSortBy...
ReDim Preserve aFiles(.FoundFiles.Count)
For i = 1 To .FoundFiles.Count
aFiles(i) = .FoundFiles(i)
Next i
End With
gFindFiles = aFiles
Erase aFiles
End Function
I'm sending in the correct parameters but it's reporting
You entered an expression that has an invalid reference to the property FileSearch.
I can't figure out why, any help appreciated.