Apply passwords to open on multiple files

G

Guest

Scenario: one folder(x) contains 3 files (without a password to open) name
a, b, & c. A separate file(z) contains a list of file names and
corresponding passwords for files in folder(x). See below:

File Password
a 123
b 456
c 789

What I would like is to build a macro that cycles through the files in
folder(x), looks up the corresponding password in the password file(z), and
applies as open-file passwords to the files in folder(x).

Thanks.
 
M

ManualMan

Hi,

It would be simpler to start with the list in file z, instead of folder
x

'cycle through rows in file z

myworkbook=some_range_from_file_z
mypassword=some_range_from_file_z

Workbook.Open myworkbook 'don't forget to include full path!!!
ActiveWorkbook.Protect Password:=mypassword, Structure:=True,
Windows:=False

'next cycle

If you insist on cycling through the folder, you should use
FileScriptingObject, or FSO. Some cool examples can be googled.
Regards,
ManualMan
 

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