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!

File Search Directory 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
 
I would you recomend you to use API:
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long

Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long

Declare Function FindClose Lib "kernel32" Alias "FindClose" (ByVal hFindFile As Long) As Long
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top