Try Something Like this:
Code:
Private Sub Command1_Click()
MsgBox FindFile(Text1, "C:\")
End Sub
Function FindFile(ByVal sFileName As String, Optional ByVal sInitPath As String) As String
If IsMissing(sInitPath) Then sInitPath = CurDir
Dim aSubDirs() As String
Dim iDirs As Long
Dim sDir As String
If Right$(sInitPath, 1) <> "\" Then sInitPath = sInitPath & "\"
sDir = Dir(sInitPath & "*", vbDirectory + vbNormal + vbHidden + vbReadOnly + vbSystem)
While Len(sDir)
If LCase(sDir) = LCase(sFileName) Then
FindFile = sInitPath & sDir
Exit Function
Else
If (GetAttr(sInitPath & sDir) And vbDirectory) = vbDirectory And Left$(sDir, 1) <> "." Then
ReDim Preserve aSubDirs(iDirs)
aSubDirs(iDirs) = sDir
iDirs = iDirs + 1
End If
End If
sDir = Dir
Wend
If iDirs Then
For iDirs = 0 To UBound(aSubDirs)
FindFile = FindFile(sFileName, sInitPath & aSubDirs(iDirs))
If Len(FindFile) Then Exit For
Next
End If
End Function
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]