Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export Excel spreadsheet to access table

Status
Not open for further replies.

cassidybklyn

Programmer
Apr 23, 2007
82
US
Please can anyone assist me with the VB code to export a spreadsheett to access table(database). I am doing this and it's telling me that object is required:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "ExcelImport", "C:\UnclaimedChecksover60days_20070515_12.51.38.xls", True

Note: "ExcelImport" is my access table name.
Name of spreadsheet and its location:
"C:\UnclaimedChecksover60days_20070515_12.51.38.xls"
Both my spreasheet and Access database on located on the C:\ drive.
Thanks.
Cassidy.
 
This code should run in access VBA.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
DoCmd is a method of the Access.Application object, so to call it you must have instantiated such object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV,
I instantiated the access object as such:
Dim AccObj As object
Set AccObj = CreateObject("Access.Application")

Then I called the DoCmd, but I still got the same message: Object required.

What am I doing wrong?


 
No I just did a straight "DoCmd" as I'm in access environment. I guess that was wrong huh?
 
I can't see where you told the program to look for the db.
 
You must have an access application with an opened CurrentDatabase and use full qualified objects.

BTW, what is the meaning of I'm in access environment vs I'm running VB 6.0 ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks guys, after much tweaking, it worked like a charm, just as you said.
Thanks and STARS for y'all.
Cassidy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top