I have a folder with 2000+ excel files which I need to import into a single Access table. This would be a recurring activity (monthly) so I am looking for help to automate this task. Assuming the best way to do this is with VB but unfortunately I have no experience in this area.
Can anyone help with code that would accomplish this task? Any explanation / references would be greatly appreciated since I have very little knowledge of VB.
Here some code that should point down the right track
create the link first
Function ReLink_Execl_File(ThisFile) As Boolean
' this just relink the the Execl file
' so the MYDocs folder is on a differance each User.
Dim FilePathName As String
FilePathName = Get_MyDocs & "\" & ThisFile
If Not fileExists(FilePathName) Then
MsgBox ("C A N ' T F I N D " & vbNewLine & vbNewLine & ThisFile & vbNewLine & vbNewLine & "You Need to put file into Your 'My Documents' Folder")
ReLink_Execl_File = False
If fileExists(FilePathName) Then
DoCmd.DeleteObject acTable, "In Process"
DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel12, "In Process", FilePathName, True
ReLink_Execl_File = True
Function fileExists(s_fileName As String) As Boolean
Dim obj_fso As Object
Set obj_fso = CreateObject("Scripting.FileSystemObject")
fileExists = obj_fso.fileExists(s_fileName)
Function Get_MyDocs() As String
Set WshShell = CreateObject("WScript.Shell")
Get_MyDocs = WshShell.SpecialFolders("MyDocuments")
then just do a update query form the execl link table to main table
hope this help
See clear as mud
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment: Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010 VB based on my own environment: vb6 sp5 ASP based on my own environment: 5.6 VB-NET based on my own environment started 2007 SQL-2005 based on my own environment started 2008 MYLE YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
Thanks for the response. About 5 minutes after my original post I was able to find a piece of code which solved my problem. Unfortunately I didnt even get a chance to look at the code you provided but I will definitely save it for future use.