A
Apprentice
StrFile =
Having trouble with this code. It hangs on:
strFile = Dir(strPath & "*.xls")
Private Sub ImportCI_Click()
Dim blnHasFieldNames As Boolean
Dim strWorksheet As String
Dim strTable As String
Dim strPath As String
Dim strPathFile 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 = "C:\Documents and Settings\eberger\My Documents\ES2009"
' Replace worksheetname with the real name of the worksheet that is to be
' imported from each file
strWorksheet = "CoreItemTrends"
' Import the data from each workbook file in the folder
strFile = Dir(strPath & "*.xls")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
strTable = "tbl_" & Left(strFile, InStrRev(strFile, ".xls") - 1)
DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, strTable, strPathFile, _
blnHasFieldNames, strWorksheet & "$"
' 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
Having trouble with this code. It hangs on:
strFile = Dir(strPath & "*.xls")
Private Sub ImportCI_Click()
Dim blnHasFieldNames As Boolean
Dim strWorksheet As String
Dim strTable As String
Dim strPath As String
Dim strPathFile 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 = "C:\Documents and Settings\eberger\My Documents\ES2009"
' Replace worksheetname with the real name of the worksheet that is to be
' imported from each file
strWorksheet = "CoreItemTrends"
' Import the data from each workbook file in the folder
strFile = Dir(strPath & "*.xls")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
strTable = "tbl_" & Left(strFile, InStrRev(strFile, ".xls") - 1)
DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, strTable, strPathFile, _
blnHasFieldNames, strWorksheet & "$"
' 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