Invite User to Select File to Import

JungleJme

Registered User.
Local time
Today, 10:12
Joined
Jun 18, 2012
Messages
38
SOLVED Invite User to Select File to Import

Hi all,

I've got a line of code that opens an excel file to import it into an access table:

Code:
DoCmd.TransferSpreadsheet acImport, , "tbl_temp_sql_data", _
 "C:\Users\7092\Documents\Master\Current Work\DB Folders\sqlexec.xls", False

As you can see, the file path is hardcoded. Any idea how i could invite the user to select the file rather than hard coding it?

Soz, i'm completely new to VBA but thanks for taking a look!

J
 
Last edited:
That was quite a complicated load of code, most of it was a bit beyond me. So what i ended up with was:

Dim fd As FileDialog
Dim filechosen as string

Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Show
Filechosen = .SelectedItems(1)

' Then whatever the user selects, the import action will import, meaning i don't have to hard code the filename and path

DoCmd.TransferSpreadsheet acImport, , "tbl_temp_sql_data", Filechosen, False
 

Users who are viewing this thread

Back
Top Bottom