Hi all,
I am currently trying to create an automated process to import data from several Excel files into Access daily, which I have managed to get working, however due to the ever increasing size of the excel files I need to delete the imported data from Excel after. I have managed to find a way of deleting the entire Excel file but I don't want to do that, just the data!
The code I have so far works to import the data:
Sub ImportCreditorData()
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean
Dim strRangeName As String
' Change this next line to True if the first row in EXCEL worksheet
' has field names
blnHasFieldNames = True
' Replace C:\Documents\ with the real path to the folder that
' contains the EXCEL files
strPath = "G:\Creditor\Individual Performance\"
' Replace tablename with the real name of the table into which
' the data are to be imported
strTable = "tblCreditorTimesheets"
strRangeName = "TimesheetDataExport"
strFile = Dir(strPath & "*.xls")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, blnHasFieldNames, strRangeName
' Uncomment out the next code step if you want to delete the
' EXCEL file after it's been imported
' Kill strPathFile
strFile = Dir()
Loop
End Sub
Can anyone help me with the rest?
Many anticipatory thanks
Sazzle
I am currently trying to create an automated process to import data from several Excel files into Access daily, which I have managed to get working, however due to the ever increasing size of the excel files I need to delete the imported data from Excel after. I have managed to find a way of deleting the entire Excel file but I don't want to do that, just the data!
The code I have so far works to import the data:
Sub ImportCreditorData()
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean
Dim strRangeName As String
' Change this next line to True if the first row in EXCEL worksheet
' has field names
blnHasFieldNames = True
' Replace C:\Documents\ with the real path to the folder that
' contains the EXCEL files
strPath = "G:\Creditor\Individual Performance\"
' Replace tablename with the real name of the table into which
' the data are to be imported
strTable = "tblCreditorTimesheets"
strRangeName = "TimesheetDataExport"
strFile = Dir(strPath & "*.xls")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, blnHasFieldNames, strRangeName
' Uncomment out the next code step if you want to delete the
' EXCEL file after it's been imported
' Kill strPathFile
strFile = Dir()
Loop
End Sub
Can anyone help me with the rest?
Many anticipatory thanks
Sazzle