Access import Password protected data from Excel

G

George

Does anyone know how to do this? I have this DoCmd.TransferSpreadsheet code
in an Access 2000 database that brings in Excel data. This data wasn't
password protected but now it is. I need to know how to put code in Access
that will bring in the same data but with a password. I have over 70 Excel
files that are brought in and I don't want to open each file and unprotect it.

This is the non password protected code I'm using:
***************************
DoCmd.TransferSpreadsheet acImport, 8, "tbl_Monthly_Set_Current_Activity", _
argFileName, True, "Monthly Set!a1:af2"
** *************************

These are object defintions:
tbl_Monthly_Set_Current_Activity Access database table

argFileName Excel file name

Monthly Set!a1:af2 Excel range to import


Thanks
 
A

Alex Dybenko

Hi,
what you can try - is to open excel instance via automation (createobject),
then open this file there supplying password, then run TransferSpreadsheet
and then close excel using quit method
 
G

George

Thank you Alex, but how do I do this?

Alex Dybenko said:
Hi,
what you can try - is to open excel instance via automation (createobject),
then open this file there supplying password, then run TransferSpreadsheet
and then close excel using quit method
 
G

George

Thank you so much Alex, this worked!

I have another question about this code. Since I'm opening up the Excel
file
and right after the oWB.Close closing code executes, I get the Excel prompt
"Do you want to save changes to the Contact.xls? yes or no or cancel. How
do I get rid of the prompt? The answer would be no I do not want to save.
 
M

Martin

Hi Alex

Thanks for your code - it's good and works some of the time. The only
problem is that the .Quit and setting oExcel to Nothing doesn't seem to work
and I'm always left with an invisible Excel running in memory (viewable from
the Processes tab of the Task Manager). My Access then crashes if I try to
run the code again.

Any ideas?

Martin
 

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