Error in Function Access 2007 OK in Access 2003

kirkm

Registered User.
Local time
Today, 18:04
Joined
Oct 30, 2008
Messages
1,257
This function has worked for me in all Office applications until now, when I am trying to use Access 2007 and Windows 7.

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.
 
Thanks Gasman, should have googled more!
Funny thing though, it does work with Excel 2007.
 
No one has ever said MS are consistent. :)

What would be the harm of leaving it in?

It'd the old adage 'If it isn't broke, don't fix it'. :)
 

Users who are viewing this thread

Back
Top Bottom