It doesn't really do that. What you do is call the GetOpenFile function and
it will present a dialog box that you can then navigate to the folder you
want and look at the file names. You will want to probably comment out or
change this line:
strfilter = ahtAddFilterItem(strfilter, _
"Access (*.mdb)", "*.MDB;*.MDA")
It restricts what you see in the dialog to only those file types. The
GetOpenFile function in what you downloaded is really only an example, but it
will give you are starting point. Comment out that line, and you will see
all file types. What happens then is you click on a file and it returns the
file name and path for the file you clicked on. It is just the Windows File
Open dialog. You will recognize it as soon as you see it. Try this. Open
your VBA Editor, select the module you have that code in and Comment out the
line of code above. Then go to your immediate window and type in:
X = GetOpenFile()
One the dialog pops up, navigate to a folder, and double click on any file.
The dialog will dissapear. Now type in:
?X
The path and name of the file you clicked on will show up.
I was suggesting this as a solution since you will not know the file name,
you should be able to determine which file is the one you want. If you click
on the view menu icon (rightmost on the tool bar), you can select Details,
and be able to see the file attributes.
Now, you can put the call to the GetOpenFile function in the click event of
a command button to do the import:
SomeVar = GetOpenFile
If SomeVar <> "" Then
DoCmd.TransferText acImportDelim, , "ImportTableName", SomeVar
End If
The acImportDelim may not be correct for your file type. You will have to
make changes to suit your situation. If, in fact, it is a text file, I would
recommend you do the import once by hand so you can set up an import
specification. Once you have done the File, Get External Data, Import and
selected a file, you will get an Import Wizard. Click on advanced. Here you
can specifiy field names and data types and which fields you want to imort.
Then click on Save As and give it a name. Then in your TransferText, you can
give it that name in the Specifation argument and it will really help get the
data in cleaner:
DoCmd.TransferText acImportDelim, MySpecName, "ImportTableName", SomeVar
Hope this will help.