File path extracted to the cell in lowercase and sometimes it does

A

Adnan

I have some code that extract file paths and lists them in Sheet1 (rows1 thru
whatever many they may be). The issue is, recently it lists them all in lower
case (paths in lowercase) instead of like before proper case as you see it on
Address bar of the folder. The other issue is, sometime when I hit the find
button, I get the message ‘No files found’ and I know they are there (at
which case I’d have to restart the computer to avoid this message).

Does anyone have any idea as to why these two strange behaviors happen
recently?

Thanks for any help provided,
Adnan
 
A

Adnan

Here's the code Nigel,


Sub SearchFiles()
Dim stPath As String
Dim fnr As Long
Dim c As Long

'Search for files:
Set fs = Application.FileSearch
Sheets("Sheet1").Select
Range("A6:B5000").ClearContents
stPath = Trim(Cells(1, 2).Value)

With fs
.LookIn = stPath
.Filename = "*.xls"
.SearchSubFolders = False
c = 6

If .Execute() > 0 Then

For i = 1 To .FoundFiles.Count
Cells(c, 2).Value = .FoundFiles(i)
fnr = .FoundFiles.Count
Cells(5, 3).Value = fnr
c = c + 1
Next i

Else

MsgBox "No Files Found"
Cells(5, 3).Value = 0

End If
End With
Application.Calculation = xlCalculationAutomatic

End Sub


The thing is, I think it is not the code since it was okay few days ago.
Thanks for you help,
Adnan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top