I have an Excel VBA procedure which checks a folder to see if there is any file residing there. If there is then it copies the file to a destination folder.
However, because the file check is in a For Next loop, and even though I only have one file in the folder, it processes an 'invisible' file before exiting the loop. I know this because when I put it in Debug and test the values it shows the second time around the loop that the 'filename' is "Thumbs.db". God knows where this file has come from because it doesn't display in Windows Explorer.
Consequently it is affecting my processing because my filename variable changes to this value.
Any clue as to what this might be ? How can I test the folder without having to loop, as I'll only ever have either no files in the folder or only one file in the folder.
My code is enclosed...
' Check if a file has been moved into the Input folder
Set fs = CreateObject("Scripting.FileSystemObject")
strSourceFolder = "C:\Users\Toco\Status Report\Data\Input"
strDestinationFolder = "C:\Users\Toco\Status Report\Data\Archive"
Set r = fs.GetFolder(strSourceFolder)
For Each f In r.Files
fs.CopyFile strSourceFolder & "\" & f.Name, strDestinationFolder & "\" & f.Name
strFileName = f.Name