Dialog Box to Select Import File

G

Guest

I'm using the TransferSpreadsheet method to import an Excel sheet into Access.
DoCmd.TransferSpreadsheet acImport, 5, "TempDHU", "\\Path\Master.xls", -1

Instead of naming a specific Excel workbook to import (Master.xls), is there
a way to get a dialog box (like the Import File dialog) so the user can
select the folder and file to import?
Thanks.
 
G

Guest

Wow! Thanks for the help but that's way over MY head.
Any suggestions on how I learn to read that stuff?
I tried some cut and paste and some changes but couldn't get anything to work.
Thanks anyway.
 
G

Guest

Hi,

If you know how to do it, it is quite simple.

1. copy the whole code with the blue background - without amendments - into
an own module.

2. Add the following lines to a Function in another module

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)

And to import the file use the DoCmd.TransferSpreadsheet command. In your
example it would be
DoCmd.TransferSpreadsheet acImport, 5, "TempDHU", strInputFileName, -1

(Instead of the '-1' I prefer 'True')


HTH
Bernd
 

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