Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel File Search Problem

Status
Not open for further replies.

jbhill001

Technical User
Dec 10, 2002
3
US
I'm new to most of this so can anyone tell me what I am doing wrong? I get a Invalid Procedure Call or Argument when I change the .LookIn directory to something other than e:\drew
Thanks! Jason

Private Sub CommandButton1_Click()
Range("A2:C40000").Clear
r = 2
TheDate = Format(Now(), "mm/dd/yy")
Range("e1").Value = TheDate
Range("f1").Value = (Range("e1").Value) - 1
With Application.FileSearch
.NewSearch
.LookIn = "\\borg\HIX Docs\Beckwith\"
.FileName = "*.dwg"
.SearchSubFolders = True
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
Else
MsgBox "There were no files found."
End If

For i = 1 To .FoundFiles.Count
Test = Format(FileDateTime(.FoundFiles(i)), "mm/dd/yy")
If Test > Range("f1").Value Then
Cells(r, 1) = .FoundFiles(i)
Cells(r, 2) = FileLen(.FoundFiles(i))
Cells(r, 3) = Format(FileDateTime(.FoundFiles(i)), "mm/dd/yy")
r = r + 1
End If
Next i
End With
End Sub
 
Jason,

In your LookIn property, try quallifying the path to the drive rather than \\.

Also, if there are no files found, you might want to exit the sub rather than continuing. :) Skip,
SkipAndMary1017@mindspring.com
 
Thanks for the help but I'm a little slow...

What do you mean by quallifying the path? I've tried the \\ approach and the e:\ approach and both of them work with only one folder on the drive. I think the .FileName = "*.dwg" might be causing a problem. One other thing, the .SearchSubFolders = True, what if there aren't any subfolders in the directory? Could that be the problem?

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top