Importing password locked Sheet

R

Rivers

Ok guys Ive seriously come up against it.

I had a program that ran perfectly it ripped attachement emails and imported
a psecif sheet

However now the spreadsheet has been locked (O Joy) now my program though up
the error cant decrypt file so i went through forums going pillar to post and
found

http://accessblog.net/2005/04/how-to-import-password-protected-excel.html

ok so now i had this program which before i give my problem is a brilliant
piece of code however

My Access keeps crashing while using it or sending me a message saying i can
now veiw this file for editing or readonly purposes also the excel files will
not close i tried everything written on that page but it still wont close
down excel i keep getting about 20 instances of excel opened invisible in the
back ground

heres my code

this is called with in a loop where filename1 keeps changing strpassword is
static to one password for all


Public Sub ImportProtected(Filename1, strPassword)
Dim oExcel As Object, oWb As Object
Set oExcel = CreateObject("Excel.Application")
Set oWb = oExcel.Workbooks.Open(Filename:=Filename1, Password:=strPassword)
oWb.unprotect (strPassword) 'new code
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
"0_tbl_GRN_Import", Filename1, True, "Import!A:I"
DoCmd.SetWarnings False
oWb.Close SaveChanges:=False
Set oWb = Nothing
oExcel.Quit

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top