Solved

code to import data to access 2013 database from excel 2013 file

Posted on 2014-07-20
2
1,655 Views
Last Modified: 2014-07-20
hi

i have a code that  seems to be excellent and professional (a code that prevent duplicates and check headers etc.) to import data from an excel file (code source  there) but i don't understand how exact the code is working. the function name is "ImportSpreadsheet" and the code is  on  a modle with the name "basImportXLS". i try to call this function on form "form1" with no success. i will be very thankful if someone will help me to use this function. i attached the access database and an excel file that it's came with this code.
TestData.xlsx
ImportXLS.accdb
0
Comment
Question by:bill201
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40207919
The "basTest" module includes a method named "TestImport". That shows you exactly how to use it. You would essentially duplicate that code in the Click event of your Command0 button.

Obviously, you'd need to know the full path to the file before you run this line:

   Set xlb = Excel.Application.Workbooks.Open("C:\TestData.xlsx")
 
That said, I really don't see any need to automate an instance of Excel just to import data. Instead, use TransferSpreadsheet to move your data from the Excel sheet into a "staging" table, and then use standard VBA/SQL to check it and move it to your "live" tables.
0
 

Author Closing Comment

by:bill201
ID: 40207987
Excellent answer. Thanks alot
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question