Use password to remove controls set by Macro
Closed
Kyle
-
Oct 17, 2011 at 12:10 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Oct 20, 2011 at 08:59 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Oct 20, 2011 at 08:59 AM
Related:
- Use password to remove controls set by Macro
- Ubuntu remove password - Guide
- Kmspico password - Download - Other
- Winrar set password not working - Guide
- No email no password - Guide
- How to remove deep freeze without password - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Oct 18, 2011 at 10:39 AM
Oct 18, 2011 at 10:39 AM
HI Kyle,
See if this yields the desired result:
Create a button and goto the properties of the button.
Change (Name) into: cmdProtection
Change Caption into: Click here to protect all sheets
Still being in design mode, right-click the button and select view code.
Use this code:
Now change everything/something/nothing between two double quotes ("") to suit your personal style.
Best regards,
Trowa
See if this yields the desired result:
Create a button and goto the properties of the button.
Change (Name) into: cmdProtection
Change Caption into: Click here to protect all sheets
Still being in design mode, right-click the button and select view code.
Use this code:
Private Sub cmdProtection_Click() Const PW As String = "Password" Dim ws As Worksheet Dim x As String x = InputBox("Please provide password") If cmdProtection.Caption = "Click here to protect all sheets" And x = PW Then For Each ws In Worksheets ws.Protect Password:=PW, DrawingObjects:=True, Contents:=True, Scenarios:=True Next ws cmdProtection.Caption = "Click here to unprotect all sheets" ElseIf cmdProtection.Caption = "Click here to unprotect all sheets" And x = PW Then For Each ws In Worksheets ws.Unprotect Password:=PW Next ws cmdProtection.Caption = "Click here to protect all sheets" End If End Sub
Now change everything/something/nothing between two double quotes ("") to suit your personal style.
Best regards,
Trowa
Oct 19, 2011 at 08:56 AM
In my code I have:
Private Sub Workbook_Deactivate()
Call ToggleCutCopyAndPaste(True)
End Sub
how could we ues this to create a button that is password enabled to Activate the 'ToggleCutCopyPaste'
Kyle
Oct 20, 2011 at 08:59 AM
Does this work for you?:
Have no idea if this would work for you since I do not know what code is behind "ToggleCutCopyAndPaste".
"Private Sub Workbook_Deactivate()" will make the code run when you exit the workbook and is no option when you want to use a button.
Best regards,
Trowa