Using Application.FileSearch in Access 2007

C

Chip

I have an Access 2003 application that I had to convert to Access 2007. I
use Application.FileSearch to go to a specified directory, report the number
of files found, import the files one by one and process them, then delete the
files from the directory so it is empty for the next set of files to be
added. My code is:

Dim fs, fn, fi 'stands for FileSearch, fn = filename, fi = file imported

Set fs = Application.FileSearch
With fs
.LookIn = "C:\Brinks\CurrentFiles"
.filename = "DEIBOLD*.CSV"
If .Execute > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For I = 1 To .FoundFiles.Count
MsgBox .FoundFiles(I)

When I get to the line: Set fs = Application.FileSearch, I received a
runtime error 2455, you entered an expression that has an invalid reference
to the property FileSearch.

I can't get past this line of code. Research tells me I'm missing an object
library called Microsoft Office 2007 Access database engine Object Library.
I already have one called Microsoft Office 12.0 Access database engine Object
Library, but that doesn't find the "Application.FileSearch property.

Has anyone had this problem? Does anyone know how to resolve this issue?
I'm at my wit's end.

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...aab61&dg=microsoft.public.access.externaldata
 
C

Chip

Doug,

You are right - it just doesn't exist anymore. I really appreciate the
input, however, you are way over my head, but I will keep working at using
your code to suit my purpose because I can see how it works, I just can't
make it do what I need it to do. Thanks so much for taking the time to
respond.
 
D

David W. Fenton

I have an Access 2003 application that I had to convert to Access
2007. I use Application.FileSearch

As you've found out, FileSearch was removed from O2007.

I haven't programmed any apps in A2007, but for a client project
that began in late May, I needed the functionality. So I rolled my
own. I never got around to finishing it for public use, nor finished
writing it up, but you can download it here:

http://dfenton.com/DFA/download/Access/FileSearch.zip

If you want to see the discussion of it, you should check Google
Groups under my name with the word "FileSearch".

I've implemented all the properties your short code snippet uses,
and the equivalent code using my class module would be:

Dim fs As New clFileSearch

With fs
.LookIn = "C:\Brinks\CurrentFiles"
.filename = "DEIBOLD*.CSV"
If .Execute > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For I = 1 To .FoundFiles.Count
MsgBox .FoundFiles(I)

In other words, you change the type declaration on your FileSearch
object to be an instance of my class module, and it all works.

These are the properties/methods I haven't implemented (because I
can't, or don't consider them worth implementing):

' PROPERTIES
' Application : irrelevant
' MatchAllWordForms : not implemented
' PropertyTests : not implemented
' SearchFolders : not implemented
' SearchScopes : not implemented
'
' METHODS
' RefreshScopes : not implemented

Everything else is implemented, along with several additional
properties/methods I added to extend the basic FileSearch
functionality to meet the needs I had.

It could be that the version on the website is not fully up-to-date,
as the first app I used it in caused me to fold some changes back
into it, and I didn't do the actual implementation until late June.
This included some UI things, like adding a custom progress bar,
hookable from the class module.

If you have any questions, don't hesitate to ask.
 
C

Chip

David,

I believe this will work for me. Thank you very much for your reply and the
use of your database. This may solve other problems for me as well.
 
D

David W. Fenton

I believe this will work for me. Thank you very much for your
reply and the use of your database. This may solve other problems
for me as well.

I'm glad it looks like it will help you. It was quite a fun project,
actually, and I was able to accomplish a lot more than I expected
to.

If you run into any problems, post here in the newsgroup. I'd be
happy to try to solve any issues you encounter, as, of course, you
may need things I haven't tried, or attempt something that I never
did and find a bug.

I really should get the updated version on my website and finish
writing the documentation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top