Looking for files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know I can use VBA to see whether a particular file exists. However, can I
use VBA to see whether a folder contains one or more files (name or names
unknown)? Secondly, can I use VBA to get the filename of the first file in
the folder? If yes, could you please point me in the right direction?
Thanks.
 
Have a look at the DIR function.
If you call it using the path, it will return an empty string if there
is no file or the first file name.
Something like the following, but you will need to look up the help for
the specifics.

Dim strFileName as String
strFileName = Dir("C:\MyDirectory")

Regards,
Andreas
 
Back
Top