Importing Excel tabs in Access

D

dimpie

Hi - I have a excel spreadsheet with 10 tabs and i would like to import only
2 of them which are randomly placed.

I would like to know how to import the specific tabs using the code

docmd.transferspreadsheet

Thanks for all the help.
 
K

Klatuu

Put the name of the spreadsheet tab in the Range argument of the
TransferSpreadsheet method.
 
D

dimpie

I tried this, it is still importing the first tab.


DoCmd.TransferSpreadsheet acImport, , "tbl_West_ESPN", S:\File
Management\Automation\Autofall\PS1_WEST.xls, ,ESPN2

Is there anyting wrong with the above code?
 
K

Klatuu

It needs to be in quotes.
DoCmd.TransferSpreadsheet acImport, , "tbl_West_ESPN", S:\File
Management\Automation\Autofall\PS1_WEST.xls, ,"ESPN2"
 
D

dimpie

When i run this with quotes, i have a run time error:
"The microsoft jet database could not find the object"

Here is the updated code:

DoCmd.TransferSpreadsheet acImport, , "tbl_West_ESPN", PathStr &
"PS1_WEST.xls", , "ESPN2"


Please advice. Thanks

:
 
K

Klatuu

Check the spreadsheet to be sure a sheet with the name ESPN2 exists and that
there are no leading or trailing spaces in it.
Also, you have it coded so that the spreadsheet has no field names in the
first row. Is that what you want?
 
D

dimpie

Still same error!!. I even changed the name of the tab, but still no luck.

I do not have field name in the firstrow, so i have left it blank.

any other ideas.
Thanks for your patience.
 
K

Klatuu

Sorry, not having it in front of me I can't debug it. I know this works
because I use it.
 
Top