H
Harold
My Access 2002 app uses the following code to open Excel
and loop thru a wrokbooks worksheets. The code works but
the Excel won't come out of memory (Task Mgr). What am I
missing?
Dim objExcel As Object
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open (strFile)
For Each Worksheet In objExcel.Worksheets
Dim db As DAO.Database, t As DAO.TableDef, i As Integer
Set db = CurrentDb()
For i = db.TableDefs.Count - 1 To 0 Step -1
Set t = db.TableDefs(i)
If t.Name = Worksheet.Name Then
db.TableDefs.Delete t.Name
End If
Next i
db.Close
rstTARGET.AddNew
DoCmd.Echo True, "Processing Import of " & Worksheet.Name
DoCmd.TransferSpreadsheet acImport, 8, Worksheet.Name,
strFile, False, Worksheet.Name & "!" & "A1:AH100"
rstTARGET!TBL_NAME = Worksheet.Name
rstTARGET.Update
Next Worksheet
objExcel.Application.ActiveWorkbook.Save
objExcel.Quit
Set objExcel = Nothing
and loop thru a wrokbooks worksheets. The code works but
the Excel won't come out of memory (Task Mgr). What am I
missing?
Dim objExcel As Object
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open (strFile)
For Each Worksheet In objExcel.Worksheets
Dim db As DAO.Database, t As DAO.TableDef, i As Integer
Set db = CurrentDb()
For i = db.TableDefs.Count - 1 To 0 Step -1
Set t = db.TableDefs(i)
If t.Name = Worksheet.Name Then
db.TableDefs.Delete t.Name
End If
Next i
db.Close
rstTARGET.AddNew
DoCmd.Echo True, "Processing Import of " & Worksheet.Name
DoCmd.TransferSpreadsheet acImport, 8, Worksheet.Name,
strFile, False, Worksheet.Name & "!" & "A1:AH100"
rstTARGET!TBL_NAME = Worksheet.Name
rstTARGET.Update
Next Worksheet
objExcel.Application.ActiveWorkbook.Save
objExcel.Quit
Set objExcel = Nothing