473,756 Members | 7,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automated import Excel --> Access

I have 400 different Excel-spreadsheetfile s, same structure, all with only
one record in it, and all residing in the same folder. Every now and then
new Excel files are being added. In my Access file I have a form and via a
button on that form I would like to periodicly automatically import all of
those (new) Excelfiles in an Access table with an identical structure.
What's the easiest way of making such an automated import? Is this doable?
Thanks,
john
Jul 20 '06 #1
2 9233

john wrote:
I have 400 different Excel-spreadsheetfile s, same structure, all with only
one record in it, and all residing in the same folder. Every now and then
new Excel files are being added. In my Access file I have a form and via a
button on that form I would like to periodicly automatically import all of
those (new) Excelfiles in an Access table with an identical structure.
What's the easiest way of making such an automated import? Is this doable?
Thanks,
john
Definitely doable.

First thing to do is to create an import specification where you map
the fields in the spreadsheet to types and fields in your table. (I do
it because then Access won't make some stupid proxy decision for me and
screw up.) then you could use something like the BrowseFolder API to
select a folder (at www.mvps.org/access) and then loop through the
Excel files in the folder, importing them through code.

Something like this should work

Public Sub ImportFilesInDi rectory()
Dim strPath As String
Dim myFile As String

strPath = BrowseFolder("S elect a folder to process")

myFile = Dir(strPath & "\*.txt")
Do While myFile <""
DoCmd.TransferT ext acImportDelim, "MySpecificatio nName",
"DestinationTab le", myFile, False
myFile = Dir
Loop
End Sub

Jul 20 '06 #2
Thanks Piet. Right now this seems over my head. I have some programming
experience but not in VB. I do want to try to make it work though, so a few
questions:

1. How do i save an importspecifica tion? and where are they stored? If I
import via the wizard there is no option to store the importspecifica tion.

2. In a button I put the following code but the debugger says it can't
compile from the DoCmd part on, because of a syntax error.

Option Compare Database

Public Sub ImportFilesInDi rectory()
Dim strPath As String
Dim myFile As String

strPath = "C:\temp"

myFile = Dir(strPath & "\*.txt")
Do While myFile <""
DoCmd.TransferT ext acImportDelim, "MySpecificatio nName",
"DestinationTab le", myFile, False
myFile = Dir
Loop
End Sub

The BrowseFolder gives a compile error (sub of funtion is not defined).
I probably put the code in the wrong place...

Btw: I'm using Access 2002.
john

<pi********@hot mail.comschreef in bericht
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
>
john wrote:
>I have 400 different Excel-spreadsheetfile s, same structure, all with
only
one record in it, and all residing in the same folder. Every now and then
new Excel files are being added. In my Access file I have a form and via
a
button on that form I would like to periodicly automatically import all
of
those (new) Excelfiles in an Access table with an identical structure.
What's the easiest way of making such an automated import? Is this
doable?
Thanks,
john

Definitely doable.

First thing to do is to create an import specification where you map
the fields in the spreadsheet to types and fields in your table. (I do
it because then Access won't make some stupid proxy decision for me and
screw up.) then you could use something like the BrowseFolder API to
select a folder (at www.mvps.org/access) and then loop through the
Excel files in the folder, importing them through code.

Something like this should work

Public Sub ImportFilesInDi rectory()
Dim strPath As String
Dim myFile As String

strPath = BrowseFolder("S elect a folder to process")

myFile = Dir(strPath & "\*.txt")
Do While myFile <""
DoCmd.TransferT ext acImportDelim, "MySpecificatio nName",
"DestinationTab le", myFile, False
myFile = Dir
Loop
End Sub

Jul 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1611
by: Soundneedle | last post by:
(AC2003, XL2003) Can anyone explain how I can get the transferspreadsheet function to upload a sheet that has number for the field names? Access converts the field header to "F##". In other words, my Excel sheet being uploaded has field names/headers in row 1 (like "Header Title A", "Header Title B" , "1", "2", "3"). When importing using the TransferSpreadsheet function, the first two header names are assigned/converted ok, but the...
6
5714
by: Syvman | last post by:
Here's what I've got: I'm trying to grab some data out of an Excel spreadsheet and bring it into Access. I'm able to do it, but only if the Excel spreadsheet is not opened by any other users. I am connecting to the spreadsheet via ADO (Jet OLE 4.0 Provider). If the file is opened for editing by another user, I receive the "The Microsoft Jet database engine cannot open the file ". It is already opened exclusively by another user, or...
3
7477
by: Santa-D | last post by:
I've got an excel sheet that I need to import into a table, however, I want the function to automatically manipulate the data prior to it being imported. For example, i have a field called and the format is 16107 for example, when the VBA function is running I want it to add "EA" to the record so it becomes EA16107 but the field I want it to import into is called another field in the same dataset I want to import is , this
2
7154
by: ruthboaz | last post by:
Hi, I am exporting a table with data to an excel file.. Some fields are empty in the exported file while the others and the key field, has values. The empty field(s) in excel, will be entered with values by another department. I require to update the access db from the updated excel fields to the respective fields in the database.. While using import from the file menu, I see that the information is append the table..
1
1936
by: Patonar | last post by:
Hi, I would like to be able to using VBA from an Excel macro - go through each line in my spreadsheet and add to a database. I know that this can be done via the import external data tool in access but the final solution i am working towards will allow the user to select columns from randomly formatted datasets in excel. I already have code that loops through every row in my excel file to
2
6919
by: Quique | last post by:
Hello, I've got a problem importing a worksheet Excel into a temporary table in access. All the information is imported but the table is not ordered as it is originally in excel. I'm using a VBA code rather simple as the following: Private Sub Import() ... Dim TableName As String
3
3614
by: MarcGA | last post by:
(Excel 2003, Access 2003, XP, novice user here) I can't get Access to accept multiple Excel files to the same table. I can import the spreadsheets to a new table, but I need to import 23 spreadsheets to the same table. I'm not getting a formatting error, just a "file did not import" message. Also, when I do import one-to-one, Access inserts thousands of blank lines before the first line of imported data. How do I keep Access from doing...
3
2212
by: derfer | last post by:
I am trying to import a .inf file into access (the file comes from the output of some 3rd party software). I have managed to convert the file by opeing it in notepad and re-saving then a seperate script to open the txt file and import. Both these scripts seem to work well (ish) but is there a better way of doing this? and is there a way of doing this and only having to run a single script? Copies of the script below. Any help would be much...
2
2187
by: OpusMagnum | last post by:
I'm trying to import an Excel spreadsheet and append a current table within the Database. I have have all the Access column names within the spreadsheet. Access wants to import a blank column and names it 'Field6'. I've tried to keep it from importing, but for some reason it wants to import that blank columns. Any suggestions?
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.