Password unprotect excel workbook depending of environ id:

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, can macro be enabled before workbook is unprotected so that it runs thisworkbook open code and unprotect the workbook by itself user dont have to actually unprotect the workbook?

When i ask this, i dont mean open workbook from another workbook...

Thanks for any advice.:)
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi. Do you mean like this?

Code:
Private Sub Workbook_Open()
If Environ("username") = "Pedie" Then Me.Unprotect Password:="Pedie"
End Sub
 
Upvote 0
Peter, thanks. I tried this way but it still promts me for password...and now i think the password i supplied is also wrong...it won't even open up with the correct password:


Thanks again
 
Upvote 0
Peter:)....i do not want to bypass it.
I know the password it is "123" testing password.

It still pops up password dailog box even though i have conditioned my environ's id correcly.
 
Upvote 0
I exactly tried this way and it still ask me for password:

Code:
[/FONT]
[FONT=Courier New]Private Sub Workbook_Open()
Application.DisplayAlerts = False
 'MsgBox "Ooops!"
 If Environ("Username") = "Pedie" Then Me.Unprotect Password:="123"
Application.DisplayAlerts = True
End Sub

Thanks again Peter!
 
Upvote 0
Sorry but you must have mis-typed the password when you saved it. I cannot help you but Google can.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,712
Members
452,939
Latest member
WCrawford

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