Ask User for filename

drusteeby

Registered User.
Local time
Today, 14:32
Joined
Jul 9, 2009
Messages
29
I want to create a button that users can use to import excel data straight into a table. I have all the code for the excel part but I have no idea how to ask the user for the excel file they want to use. Right now I have the filename varible manually set, is there a way that I can bring up the file dialog box and then have the excel file's location that they selected be the value of the varible? Thanks.
 
When i follow these instructions it says I do not have the rights to run the Active X control. I am at work using company software so there is nothing I can do about that. Is there any other way?
 
You can always just have the user type the path and file name in directly into a text box control.
 
Would something like this work

Code:
Dim strFilter As String
Dim strInputFileName as string

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
                Filter:=strFilter, OpenFile:=True, _
                DialogTitle:="Please select an input file...", _
                Flags:=ahtOFN_HIDEREADONLY)
 
It's been a while since I did anything with the common dialog stuff. Maybe some with more experience can help. Just curious, have you tried the code you posted to see if it would work?
 
Yea, I tried it but there are so many functions that it calls that it gets messy and doesn't work...

http://www.mvps.org/access/api/api0001.htm

Thats the site with the source code.

I'd use a textbox but it would be a pain to have to look up the file name every time. A dialog box would be more efficant.
 
"To use a 'File-Open' or a 'File-Save' dialog, download or open the following file containing Ken's code, then copy and paste the entire contents into a new module."

What does it mean by new module?
 
You can create an independent code module to have code that is not associated to a form or report. You will see it in the database window where you see tables, forms, reports, etc.
 

Users who are viewing this thread

Back
Top Bottom