G
Guest
My research has provided this code to import excel that is password
protected. The code is not working because:
1. The Spreadsheet is still asking for the password and
2. The spreadsheet remains open even but the code is supposed to close it.
Can anyone spot the error
I am using MS Office 2003 with the Access database format in 2002.
Thanks
Ross
'*******************************
Public Sub Link_Excel_Security()
'*******************************
ImportProtected "C:\A__A_Deal_Calendar\Access to Database.xls", "GMACRFC"
End Sub
'***********************************************************
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.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, "Import", strFile, -1
DoEvents
oWb.Close False
Set oWb = Nothing
oExcel.Quit
Set oExcel = Nothing
End Sub
protected. The code is not working because:
1. The Spreadsheet is still asking for the password and
2. The spreadsheet remains open even but the code is supposed to close it.
Can anyone spot the error
I am using MS Office 2003 with the Access database format in 2002.
Thanks
Ross
'*******************************
Public Sub Link_Excel_Security()
'*******************************
ImportProtected "C:\A__A_Deal_Calendar\Access to Database.xls", "GMACRFC"
End Sub
'***********************************************************
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.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, "Import", strFile, -1
DoEvents
oWb.Close False
Set oWb = Nothing
oExcel.Quit
Set oExcel = Nothing
End Sub