Searching A Folder For Files

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
 
D

Dirk Goldgar

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
 
M

Marshall Barton

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
 

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

Top