Open workbook with password in VBA

G

Guest

I have saved several workbooks in a directory that are password protected.
Using the following code, How do I tell it to use the password when it opens
the file?
MyPath is the directory path
MyFiles(Fnum) is the workbook name. This is an array of workbook names all
using the same password.

Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum))

Thanks
Shawn G.
 
G

Guest

Try this...

Set mybook = Workbooks.Open(Filename:=MyPath & MyFiles(Fnum), _
Password:="MyPassword")
 

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