PDA

View Full Version : Password to open file via macro?



dianahowe
10-14-2009, 07:43 AM
Hi,

I have a routine which takes some consolidation files, opens them, refreshes all the links within to source files, saves and closes - all very simple.

However, a couple of the source files require a password to open so at various times while the routine is running I need to type in the appropriate password.

I am therefore wondering if there is a simple way for me to supply my routine with the passwords so it can run with no supervision from me.

Any ideas? :dunno

Thanks,
Diana

JP2112
10-14-2009, 10:33 AM
The Workbooks.Open Method has a Password property you can pass at runtime. You could use something like


Dim wkb As Excel.Workbook
Set wkb = WorkBooks.Open Filename:="c:\myfile.xls", Password:="mypassword"


--JP