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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top