Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Do you know how to import the data from MS Excel into MS Access? I tried to use connection string to open MS Excel but the message says "Invalid Argument". What do I miss something?


SQL
SELECT *
FROM [Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Test.xls;
Extended Properties=Excel 8.0].[Sheet1$]
Posted

1 solution

If you don't have to do it programatically then use the data import wizard ... http://office.microsoft.com/en-gb/excel-help/import-excel-data-to-an-access-database-HP005200852.aspx[^]

If you must do it in VBA then have a look here http://www.rqna.net/qna/zrypm-import-data-from-excel-into-ms-access-closed.html[^]

Or this might work (can't test as I don't have all the right versions)
SELECT * FROM [Excel 8.0; HDR=YES; Database=C:\Test.xls].[Sheet1$]
 
Share this answer
 
Comments
Maciej Los 19-Mar-13 12:07pm    
Comment from OP:
It works with SELECT * FROM [Excel 8.0; HDR=YES; Database=C:\Test.xls].[Sheet1$]
I am wondering. Why can't we put "Provider" on it?

Thank you very much!
BeepPaulo
Maciej Los 19-Mar-13 12:09pm    
That's because MS Access database uses Jet.OLEDB.4.0 ;)
BeepPaulo 19-Mar-13 12:13pm    
I see. That make sense! :)
Maciej Los 19-Mar-13 12:10pm    
Good answer. My 5!
CHill60 19-Mar-13 12:26pm    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900