papparuff at comcast.net
papparuff at comcast.net
Mon Oct 31 09:20:12 CST 2005
This will work for you Dan,
Public Sub FindFileInSubFolders(strMainFolder As String, strFileToFind As String)
Dim fso As New FileSystemObject
Dim fsoFolder As folder
Dim fsoSubFolder As folder
Dim fsoFile As File
Set fsoFolder = fso.GetFolder(strMainFolder)
For Each fsoSubFolder In fsoFolder.SubFolders
' Debug.Print fsoSubFolder.Name
For Each fsoFile In fsoSubFolder.Files
' Debug.Print fsoFile.Name
If fsoFile.Name = strFileToFind Then
MsgBox "Found File"
End If
Next fsoFile
Next fsoSubFolder
Set fsoFolder = Nothing
Set fsoFile = Nothing
Set fso = Nothing
End Sub
--
John V. Ruff The Eternal Optimist :-)
Commit to the Lord whatever you do,
and your plans will succeed. Proverbs 16:3
-------------- Original message --------------
> I have a customer who wants their application to be able to find a file in a
> folder or subfolder based on the entry in a text box. The data entered is a
> part number, and the file to be found is the drawing for that part.
>
> However, their file structure is inconsistent. I've looked at FSO, but that
> requires that the path to a file be known. DIR is a help with the
> file/folders at the first level.
>
> Is there something that will search all the levels within a folder for a
> specific file?
>
> Thanks!
> Dan Waters
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com