datavisions
Programmer
I have code that will find the number of .TXT files in a folder. I normally only process the one that is usually found in the folder, but I need to know how to process as many .TXT files as are found. Has anyone done this before? Here's the code I use to identify ONE in the folder.
Public Function CheckAAFileExists() As Boolean
'searches the RECREPS folder for all files whose names begin with "AA" and end with ".TXT"
On Error GoTo Err_Handler
' .LookIn = "c:\FSS\IMFS\RECREPS\"
With Application.FileSearch
.LookIn = "c:\FSS\IMFS\RECREPS\"
.filename = "AA??????.TXT"
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" AA file(s) found."
CheckAAFileExists = True
gblAAFileName = Dir ("c:\FSS\IMFS\RECREPS\AA??????.TXT"
Else
MsgBox "There were no AA files found."
CheckAAFileExists = False
gblAAFileName = " "
End If
End With
Exit Function
Err_Handler:
MsgBox "Error Number: " & Err.Number & " Error: " & Err.Description
End Function
Public Function CheckAAFileExists() As Boolean
'searches the RECREPS folder for all files whose names begin with "AA" and end with ".TXT"
On Error GoTo Err_Handler
' .LookIn = "c:\FSS\IMFS\RECREPS\"
With Application.FileSearch
.LookIn = "c:\FSS\IMFS\RECREPS\"
.filename = "AA??????.TXT"
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" AA file(s) found."
CheckAAFileExists = True
gblAAFileName = Dir ("c:\FSS\IMFS\RECREPS\AA??????.TXT"
Else
MsgBox "There were no AA files found."
CheckAAFileExists = False
gblAAFileName = " "
End If
End With
Exit Function
Err_Handler:
MsgBox "Error Number: " & Err.Number & " Error: " & Err.Description
End Function