Hello,
I am using the following code to transfer data from an excel sheet into access. The code works fine except that it leaves an instance of excel running in the background. I thought that I have killed all objects running, but I can't get rid of the excel. Is there something I am missing.
Any thoughts would be a great help.
Thanks
Function fnLoadTable()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
'Delete old data from tables
CurrentDb.Execute ("DELETE tblTable.* FROM tblTable")
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(FileName:="C:\File Path\filename.xls")
'Load data from spreadsheet to table
DoCmd.TransferSpreadsheet transfertype:=acImport, TableName:="Table", FileName:= C:\File Path\filename.xls ", Hasfieldnames:=True, Range:="SheetName!", SpreadsheetType:=5
xlBook.Close
xlApp.Quit
Set xlApp = Nothing
Set xlBook = Nothing
End Function
I am using the following code to transfer data from an excel sheet into access. The code works fine except that it leaves an instance of excel running in the background. I thought that I have killed all objects running, but I can't get rid of the excel. Is there something I am missing.
Any thoughts would be a great help.
Thanks
Function fnLoadTable()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
'Delete old data from tables
CurrentDb.Execute ("DELETE tblTable.* FROM tblTable")
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(FileName:="C:\File Path\filename.xls")
'Load data from spreadsheet to table
DoCmd.TransferSpreadsheet transfertype:=acImport, TableName:="Table", FileName:= C:\File Path\filename.xls ", Hasfieldnames:=True, Range:="SheetName!", SpreadsheetType:=5
xlBook.Close
xlApp.Quit
Set xlApp = Nothing
Set xlBook = Nothing
End Function