J
John
I am using code I found in other posts by Alex Dybenko to import from Excel
into my access database. The Excel file is password protected.
This is my code:
'strFile and strPassword are supplied on a form prior to running the code.
Public Sub Test(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.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Import",
strFile, True, "test!"
oWb.Close SaveChanges:=False
oExcel.Quit
Set oWb = Nothing
Set oExcel = Nothing
End Sub
The import side of things works fine as the new table is appearing in my db,
but there is a excel.exe sitting in the background stopping the code running
again.
The data I am importing is not always on the first sheet, hence the "test!"
in the transferspreadsheet - I am wondering if this is what is causing the
problem?
Any help would be much appreciated.
Cheers
John
into my access database. The Excel file is password protected.
This is my code:
'strFile and strPassword are supplied on a form prior to running the code.
Public Sub Test(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.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Import",
strFile, True, "test!"
oWb.Close SaveChanges:=False
oExcel.Quit
Set oWb = Nothing
Set oExcel = Nothing
End Sub
The import side of things works fine as the new table is appearing in my db,
but there is a excel.exe sitting in the background stopping the code running
again.
The data I am importing is not always on the first sheet, hence the "test!"
in the transferspreadsheet - I am wondering if this is what is causing the
problem?
Any help would be much appreciated.
Cheers
John