Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2013, 09:47 AM
Registered User
 
Join Date: May 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default transfer excel data in a range to Access 2010

Hello,

I need to transfer a section of data in excel to a table in access. The excel file is current open. I want to click a button then the data in a pre-defined range will be insert into a known table in access.

The code I have is listed below. I got an error message saying "Counld not use 'xxxx'; file already in use." xxxx is this excel file's name. DataToExport is the range I defined in excel.

Please help me solve this issue! Thank you very much!!!!

---------------------------------------------------------------
Set adoCn = New ADODB.Connection
adoCn.Provider = "Microsoft.ACE.OLEDB.12.0"

sConnect = "Data Source=c:\test.accdb;Persist Security Info=False;"
sCommand = "Insert into table1 select * from DataToExport in '" & ThisWorkbook.FullName & "'"

adoCn.Open sConnect
adoCn.Execute sCommand

adoCn.Close
Set adoCn = Nothing





Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer data from Excel to Access JezLisle Excel VBA 0 December 13th, 2007 01:25 PM
Transfer Dynamic Data from Excel to Access DB ? poorheler Excel VBA 2 July 2nd, 2007 11:11 AM
Data transfer from Access to Excel swaroop Access VBA 2 June 1st, 2007 10:30 AM
how to transfer data from excel to Access database swaroop Access VBA 5 April 13th, 2007 09:02 AM
how to transfer data from excel to Access database swaroop Excel VBA 1 April 12th, 2007 10:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.