In Access VBA you would use the Dir() command. To get the first filename set you filename varibale equal to the Dir(strPathName). This will give you the first file in folder. Then subsequent calls to Dir() without specifying the folder will get the next file in the folder until Dir() returns an empty string.
Dir() will return everything in the folder, including other folders. To test whether it is a folder or not you can use:
Public Function IsFolder(strFolder As String) As Boolean
IsFolder = False
If (GetAttr(strFolder) And vbDirectory) = vbDirectory Then IsFolder = True
I am not trying to traverse the entire harddrive, just specific folders (total 6). The file names contain numbers and underscores. I believe that using Dir() (which was posted above) will solve my problem, but I haven't done any VBA scripting. I have done some VB Coding, so I should pick it up. But currently I am trying to look at some tutorials for VBA scripting, but that may take a bit. Do any of you have and good sources or ideas to get my feet wet with VBA?
Originally posted by Jerrie
you want to get the entire hard drive right? with the above method, it only goes through the folder you specify;....however, if you make it recursive, you can traverse the entire hard drive!
write a function that accepts a folder name as input; the function searches through the entire folder, and if it finds subfolders, it calls itself again for that subfolder and so on...it should work.