Pass A Password To A Protected Workbook

markkramer

Board Regular
Joined
May 8, 2002
Messages
162
Unlike the posts that I've located on the site, I actually know the password of the workbook I'm trying to open! My question is how to pass that password to the workbook in my code so that the user is not bothered with having to enter in the password (I don't want them to know it anyway).

I tried this combination but that didn't do the trick:

Workbooks.Open Filename:="myworkbook.xls"
ActiveWorkbook.Unprotect Password:="abcd1234"

Somehow I need to open the workbook and pass the password at the same time.

Thanks for you help!

M
 
Wait! One of my coworkers just figured it out. Here's the command:

Workbooks.Open Filename:="myworkbook.xls", Password:="abcd1234"

That opens the workbook and passes the password all in one command. And no dialog box!

Thanks everyone for all your help!

M
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Markkramer,
(didn't feel bad, be sure, didn't had the feeling you threw me off)
You are making clear to everyone what pennysaver already understood
in fact your workbook is protected from the "outside": so you need to undo the protection of the file itself
Workbooks.Open Filename:="myworkbook.xls", Password:="abcd1234"

regards,
Erik

EDIT: what a quick thread (quicker than me inventing english words!)
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top