ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   filesearch not finding files (https://www.excelbanter.com/excel-programming/321057-filesearch-not-finding-files.html)

Kevin

filesearch not finding files
 
I have just reinstalled my development tools (Visual Studio .net and VS for
Office 2003) and my code for FileSearch is no longer finding files. The code
is as follows

Dim fs As FileSearch

Dim strFile As String

' Declare filesearch object.
Set fs = Application.FileSearch
With fs
.NewSearch
.SearchSubFolders = False

' Set folder to search.
.LookIn = strDir

' Set file name to search for.
.FileName = "*.*"
lngCount = 0

' Execute the file search, and check to see if the file(s) are
' present.
If .Execute 0 Then
Me.lstFiles.Value = ""
' Loop through all found file names and fill the list box.
For intLoop = 1 To .FoundFiles.Count
strFile = .FoundFiles(intLoop)
strFile = Check_If_PDF(strFile)
If strFile = "" Then
Else
Me.lstFiles.AddItem strFile
lngCount = lngCount + 1
End If
Next intLoop
End If
End With

When I run this code on another machine it works fine. The above code is a
standard I use on Access and Excel and whilst the folders I am searching
contain files that should be returned, the code says there is nothing.

Any ideas or is this a new bug.

Kevin

filesearch not finding files
 
Having just dug further into the questions posed on this site, it seems that
FileSearch is considered a problem.

If anyone has any idea of why FileSearch should stop working, I would be
interested, otherwise no problem.

I will go with some of the other solutions shown here.

"Kevin" wrote:

I have just reinstalled my development tools (Visual Studio .net and VS for
Office 2003) and my code for FileSearch is no longer finding files. The code
is as follows

Dim fs As FileSearch

Dim strFile As String

' Declare filesearch object.
Set fs = Application.FileSearch
With fs
.NewSearch
.SearchSubFolders = False

' Set folder to search.
.LookIn = strDir

' Set file name to search for.
.FileName = "*.*"
lngCount = 0

' Execute the file search, and check to see if the file(s) are
' present.
If .Execute 0 Then
Me.lstFiles.Value = ""
' Loop through all found file names and fill the list box.
For intLoop = 1 To .FoundFiles.Count
strFile = .FoundFiles(intLoop)
strFile = Check_If_PDF(strFile)
If strFile = "" Then
Else
Me.lstFiles.AddItem strFile
lngCount = lngCount + 1
End If
Next intLoop
End If
End With

When I run this code on another machine it works fine. The above code is a
standard I use on Access and Excel and whilst the folders I am searching
contain files that should be returned, the code says there is nothing.

Any ideas or is this a new bug.



All times are GMT +1. The time now is 09:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com