Polling is pretty easy; You just set up some timer routine (a stopwatch on a form is a
great way to do this).
At each time period, you read the filenames out of the predefined folder.
Having processed a file, you can move it to a different location (which is the best process, I feel)âbeing sure to set up your code to gracefully handle problems like trying to copy the file if a file of that name already existsâor delete it (second best), or keep track of what you have already processed, and ignore files still in the folder but already processed.
You can look for files with Dir() and a loop (see code at the bottom of this post), or you can use the FileSystemObject (which I love).
Having found a possible processing candidate, you can get the fileâs date/time stamp, or you can rely on the fileâs name.
You can add controls allowing the user to have a calendar/clock type interface that is more human-friendly, and convert their input to the computer-friendly string that you indicate the files carry as their name.
To use the FileSystemObject, add a reference in your project to the Microsoft Scripting Runtime (C:\WinNT\System32\scrrun.dll, on my machine). Help can provide you additional details on this really helpful class.
Does that help?
Code:
Dim s As String
s = Dir$("C:\TheFileLoc\*.csv") ' returns just the filename.ext
Do Until s = ""
Process("C:\TheFileLoc\" & s) ' Process would be a user-defined routine
s = Dir$() ' REturns name of next file fitting initial speci-
Loop ' fication, or "" is no more.