Here is the code that creates the links (I call it in the OnOpen event of my switchboard):
Function ImportFromExcel()
Dim fs, f, s
Dim ExcelFileName As String
Dim PathToExcelFiles As String
Set fs = CreateObject("Scripting.FileSystemObject")
PathToExcelFiles = MyLocation
ExcelFileName = Dir(PathToExcelFiles, vbDirectory)
Do While ExcelFileName <> ""
If ExcelFileName <> "." And Right(ExcelFileName, 3) = "XLS" Then
Set f = fs.GetFile(PathToExcelFiles + ExcelFileName)
s = f.DateLastModified
DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, "Details$", PathToExcelFiles & ExcelFileName, True
End If
ExcelFileName = Dir
Loop
End Function
Now I need a way for all the linked data to be dumped into an Access table after the link has been established. The Access table will have all the same field names/types. It's called tblDetails. Any ideas? Note: the linked worksheets will never have the same name so using a query doesn't seem feasible, but I might be wrong. I appreciate any help you can give in this matter.
Function ImportFromExcel()
Dim fs, f, s
Dim ExcelFileName As String
Dim PathToExcelFiles As String
Set fs = CreateObject("Scripting.FileSystemObject")
PathToExcelFiles = MyLocation
ExcelFileName = Dir(PathToExcelFiles, vbDirectory)
Do While ExcelFileName <> ""
If ExcelFileName <> "." And Right(ExcelFileName, 3) = "XLS" Then
Set f = fs.GetFile(PathToExcelFiles + ExcelFileName)
s = f.DateLastModified
DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, "Details$", PathToExcelFiles & ExcelFileName, True
End If
ExcelFileName = Dir
Loop
End Function
Now I need a way for all the linked data to be dumped into an Access table after the link has been established. The Access table will have all the same field names/types. It's called tblDetails. Any ideas? Note: the linked worksheets will never have the same name so using a query doesn't seem feasible, but I might be wrong. I appreciate any help you can give in this matter.