To use the Dir function, you first invoke it with arguments, and then repeatedly invoke it with no arguments. It returns just the name of the fileââno path info. After the last file, it returns an empty string. If it is invoked again after that it raises an error.
Code:
Dim FilNm As String
FilNm = Dir("C:\Temp\*.tmp")
Do Until FilNm = ""
' Call any processing you want to do here:
ProcessMyFile FilNm
FilNm = Dir()
Loop
In the process described above your post ShaileshShinde, Folder objects are not being used (ultimately). The process laid out returns a string into FName.
If you use the Windows Scripting Runtime (FileSystemObject) the Dir() function is not the best approach.