runtime error 3161 - cannot decrypt file

hardy1976

Still learning...
Local time
Today, 01:24
Joined
Apr 27, 2006
Messages
200
Hi,

I need Access to link to an excel spreadsheet that is range password protected.

I just need a way of getting the data into Access on an ad-hoc basic.

I've tried the spreadsheet transfer method however I get the above error. Can anyone help PLEASE?!

I know the password and have tried the code below found at
http://accessblog.net/2005/04/how-to-import-password-protected-excel.html

however I cannot get it to work HELP HELP HELP
Code:
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
oWb.Close SaveChanges:=False
oExcel.Quit
Set oExcel = Nothing
End Sub
 
I just need the code to importing the data from a protected excel spreadsheet, it does not have to be the code above.
 

Users who are viewing this thread

Back
Top Bottom