Macro in MS Access to import excel file

spatel

New Member
Joined
Sep 22, 2004
Messages
14
Hello,

I am trying to create a macro in Access that'll import an excel file and append it into a access table. Currently, the macro is appending the records in the specified table howerver, I want the user to have the ability to select the file for import.

My macro is invoked by a button on my form but it'll only import the file that is specified in the path another words its static.

On the form, I want the user to select the .xls file from whatever location and then hit the button to import that file into the access talbe. How do yo do that?
 
Thanks. I just changed the .mdb to .xls to view the .xls fie. Its show up now. Thanks

For the append.

I am using a macro. Where the action is "TransferSpreadsheet" The problem is its selecting the file thorugh the FileOpen Function but then how can I save the filepath and in that macro which has the table I want to append into.

Another words, the filepath is save in a variable in the code. Do you think I can use that same variable in the macro or can I just call the function from the macro.

Basically, I just want the user to select the file via a button and then import that same file via a button. Thats it. The first half is done. How can I save the filepath from the function and then use the macro to append the records in the table.
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,215,472
Messages
6,125,005
Members
449,203
Latest member
Daymo66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top