Importing Excel data into Access

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I'm using this logic to import Excel data into Access.

Public Sub ImportProtected(strFile As String, strPassword As String)
Dim oExcel As Object, oWb As Object

Set oExcel = CreateObject("Excel.Application")
Set oWb = oExcel.Workbooks.Open(FileName:=strFile, _
Password:=strPassword)
DoCmd.TransferSpread*** acImport, _
acSpreadsheetTypeExcel9, "Import", strFile, -1
oWb.Close
oExcel.Quit
Set oExcel = Nothing
End Sub

It works great but it leaves an instance open of Excel in my task list.
Can someone tell me what is wong with this logic and why it is not actually
exiting Excel?
.


Quantcast