transfer a named range from excel to access...help

djsmarties

Board Regular
Joined
Sep 10, 2002
Messages
95
Hi, I want to import a range in an excel worksheet into access.
In access i use the transferspreadsheet action to do this. With a range defined as i.e. a1:c3 it works fine, but when i use a range name it doesn't work and i get an error message "can't find object..."

here is the code i use:

DoCmd.TransferSpreadsheet acImport, 8, "product_detail", "p:/project/country_input_template.xls", True, "product_detail"

The range in excel are columns. the reason i use a range name is because i don't import every column, for example i would not want to import colums c, f, and i. "product_detail" is the name of the range.

What's wrong with the code? I can't get it to work, i tried a lot of different things, but i always get the same error message.
Maybe it works better if i try to export from excel instead of importing using access code?
Thanks for your help.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
djsmarties - I take it that my earlier suggesiton wasn't up to scratch?
 

djsmarties

Board Regular
Joined
Sep 10, 2002
Messages
95
lasw10, i was actually afraid of hearing your suggestion, because thats exactly what i didn't want to do...studpid access. nobody else replied so i started another cry for help :) thanks anyway.
oh, i asked some other people, and you seem to be right, copy-pasting seems to be the only possibility...
 

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
the only other thing is that of course you specify the range on the sheet...so in theory you could have one VERY large worksheet as opposed to numerous smaller ones...then copy each range into a different Access Table...

Guess it depends on the volume of data you have...
 

klb

Well-known Member
Joined
Apr 3, 2002
Messages
821
dj:

I tried your code substituting my own file path (and the correct characters instead of /) and it worked fine the second time.

The first time I tried it I received the same error as you did but then I realized that the file I was trying to import from was still open. When I closed the xls file, the code worked just fine.
 

Forum statistics

Threads
1,182,135
Messages
5,933,842
Members
436,914
Latest member
Young Grasshopper

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
Top