File search routine

  • Thread starter Thread starter TC
  • Start date Start date
T

TC

I don't have Acess here to check, but that code looks ok to me. Are you 100%
positive that this is *exactly* the code you are running, and the error
occurs on the line you have stated?

TC
 
I'm trying to search the hard disk for .mdb files. I've
copies some code from the Help file but every time I run
it I get the following error: "Run-time error '5'. Invalid
procedure call or argument".

The code is:

Dim i As Integer

With Application.FileSearch
.LookIn = "C:\"
.FileName = "*.mdb"
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With

It seems it doesn't like the .FileName = "*.mdb"
statement. Can anybody help?

Miguel
 
I replaced the following line in your code:

.FileName = "*.mdb"

with this line:

.FileType = msoFileTypeDatabases

and the code worked properly. Note, also, that you will need to set a
reference to the Microsoft Office xx.x Object Library (where xx.x is your
particular version of Office).

hth,
 

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

Back
Top