database import question

A

Andrew King

I have managed to import an excel file into an access database. What I also
want to do is import the filename of the excel spreadsheet but I am unable
to do this. Can anyone help me with thiis?

Thank you in advance.
 
J

John Nurick

Hi Andrew,

It can be done, but since you don't say where you want the filename to
end up after being "imported" it's not possible to be specific.

You'll need to write VBA code. The general idea is

1) Get the filename. If you are using Access 2002 or later, you can do
this with the FileDialog() function; in earlier versions the best way is
to use the code at http://www.mvps.org/access/api/api0001.htm

2) Pass the filename to DoCmd.Transferspreadsheet to import it.
 
Top