Searching A Folder For Files

  • Thread starter Thread starter Howard Brody
  • Start date Start date
H

Howard Brody

Every week, I receive a file I need to import. I'd like
to automate the import but the file name is randomly
generated (by the company I receive it from, so I can't
change the process) and is different every week.

What I need to be able to do is search a folder for a file
with a specific extension. Has anyone done this before?

Thanks in advance!

Howard Brody
 
Howard Brody said:
Every week, I receive a file I need to import. I'd like
to automate the import but the file name is randomly
generated (by the company I receive it from, so I can't
change the process) and is different every week.

What I need to be able to do is search a folder for a file
with a specific extension. Has anyone done this before?

Thanks in advance!

Howard Brody

If you don't need the user to make a decision and pick a particular
file, but can automatically use the only one in the folder -- or the
most recently modified one in the folder -- you can use the Dir()
function to get the file. To get the most recent one, you'd use the
Dir() function in a loop, along with the FileDateTime() function.

If you want the user to pick a file, then if you're using Access 2002 or
later you can use the Application.FileDialog object to open the Windows
FileOpen dialog. If you're using an earlier version of Access you can
call the Windows API directly to open this dialog, using code you can
find at:

www.mvps.org/access/api/api0001.htm
 
Howard said:
Every week, I receive a file I need to import. I'd like
to automate the import but the file name is randomly
generated (by the company I receive it from, so I can't
change the process) and is different every week.

What I need to be able to do is search a folder for a file
with a specific extension. Has anyone done this before?

Is this what you're looking for?
http://www.mvps.org/access/api/api0001.htm
 
Back
Top