VBAmateure
New Member
- Joined
- May 13, 2016
- Messages
- 2
Hi to MrExcel staff and users,
As my username states, I am not a profesional programmer but rather a VBA amateure so - be gentle

I have been struggling with a protection issue in an Excel VBA project I am doing and just can't seem to figure out what the heck is going on in my file.
The project is quite large so it will not be possible (nor necessary) to post all the code, the problem though, is quite simple:
As my project opens the user is prompted to enter a client name or an admin/power user password.
The Workbook and its main Worksheet are then unprotected accordingly with a pre-determined password (an admin will have everything unlockked, visible and editable while a power user may edit some specific ranges).
So far so good - everything works perfectly.
A certain macro in the project saves the file after some data is updated and also exports it to a new wb (which is then closed).
After that the Workbook_Open sub is triggred and the user must, again, enter a client name or an admin/power user password.
However, this second time, for a reason I just can't seem to figure out, both the Workbook and the Worksheet are not being unprotected.
The sub is the exact one that functions when the file is opened and I have verified that the correct password is used and that the unprotect functions are actually triggred but somehow everything remains blocked.
A manual unprotect, using the same password, works but I just can't understand why the code would it work the 1st time but not the 2nd.
Any ideas ?
As my username states, I am not a profesional programmer but rather a VBA amateure so - be gentle

I have been struggling with a protection issue in an Excel VBA project I am doing and just can't seem to figure out what the heck is going on in my file.
The project is quite large so it will not be possible (nor necessary) to post all the code, the problem though, is quite simple:
As my project opens the user is prompted to enter a client name or an admin/power user password.
The Workbook and its main Worksheet are then unprotected accordingly with a pre-determined password (an admin will have everything unlockked, visible and editable while a power user may edit some specific ranges).
So far so good - everything works perfectly.
A certain macro in the project saves the file after some data is updated and also exports it to a new wb (which is then closed).
After that the Workbook_Open sub is triggred and the user must, again, enter a client name or an admin/power user password.
However, this second time, for a reason I just can't seem to figure out, both the Workbook and the Worksheet are not being unprotected.
The sub is the exact one that functions when the file is opened and I have verified that the correct password is used and that the unprotect functions are actually triggred but somehow everything remains blocked.
A manual unprotect, using the same password, works but I just can't understand why the code would it work the 1st time but not the 2nd.
Any ideas ?