Security Protection

bailey537

Board Regular
Joined
Jun 30, 2008
Messages
65
Hi

My problem is:

Is there a way to click an option button to make a workbook write protected, then another one to unprotect it with a password

thanks
 

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.
Here's a very vague answer:

One thing you can try is to use BeforeSave event of the workbook. Add the button as you were thinking. Then, in the BeforeSave event, add some code to check the state of the button. If it's in "Read Only" mode, then you will do a
Code:
Cancel = True

This will keep the workbook from saving.

You'll also need to add some code for the password stuff.
 
Upvote 0
I'm not too sure how that's going to help this situation

at the moment i am using

Sub Protect_Click()
If ThisWorkbook.ReadOnly Then
Else
ThisWorkbook.ChangeFileAccess(xlReadOnly)
End If
End Sub

Sub Unprotect_Click()
ThisWorkbook.ChangeFileAccess Mode:=xlReadWrite
End Sub

i just need to be able to apply a password to it now i think
 
Upvote 0
Welcome to the Board!

You can apply a password like so:

<font face=Tahoma>            <SPAN style="color:#00007F">If</SPAN> ActiveWorkbook.ReadOnly Then _<br>                ActiveWorkbook.ChangeFileAccess Mode:=xlReadWrite, WritePassword:="admin"</FONT>

Hope that helps,
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,958
Latest member
Hat4Life

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