Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / July 2005

Tip: Looking for answers? Try searching our database.

Need code to import multiple single worksheets with identical fiel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
In need of code - 25 Jul 2005 16:33 GMT
Need code to import multiple single worksheets with identical fields into a
single table into an Access table. I found several examples but they all deal
with with mulitple worksheets in a single book, I have several single
worksheet workbooks with identical fields.
Thanks in advance.
John Nurick - 25 Jul 2005 21:37 GMT
The VBA code below was posted by my fellow MVP Joe Fallon a while ago.
Just change the TransferText line to TransferSpreadsheet, with your
actual table and sheet names, e.g.

   DoCmd.TransferSpreadsheet acImport, _
     acSpreadsheetTypeExcel97, "MyTable", _
     "C:\MyFiles\" & strFile, True, "Sheet1$"

How to Import all Files in a Folder:

Private Sub btnImportAllFiles_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("c:\MyFiles")
strfile = Dir("FileName*.*")
Do While Len(strfile) > 0
 DoCmd.TransferText acImportDelim, "ImportSpecName", "AccessTableName",
"c:\MyFiles\" & strfile, True
 'delete the file (consider moving it to an Archive folder instead.)
 Kill "c:\MyFiles\" & strfile
 strfile = Dir
Loop

End Sub

>Need code to import multiple single worksheets with identical fields into a
>single table into an Access table. I found several examples but they all deal
>with with mulitple worksheets in a single book, I have several single
>worksheet workbooks with identical fields.
>Thanks in advance.

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.