Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bill!
-- Kent Lysell Financial Consultant Ottawa, Ontario W: 613.948-9557 "Bill Renaud" wrote: I used the following code, and it seems to work fine: Public Sub UnprotectAllWorksheets() Const strMsgBoxTitle As String = "Unprotect All Worksheets" Dim ws As Worksheet Dim strPassword As String strPassword = InputBox(Prompt:="Enter the password:", _ Title:=strMsgBoxTitle) If strPassword = "1111" _ Then For Each ws In ThisWorkbook.Worksheets ws.Unprotect Password:=strPassword Next ws MsgBox "All worksheets unprotected.", _ vbInformation + vbOKOnly, _ strMsgBoxTitle Else MsgBox "Password failed.", _ vbCritical + vbOKOnly, _ strMsgBoxTitle End If End Sub I placed a simple button from the Forms toolbar on the first worksheet, then called the macro straight from there. I didn't use a UserForm, to eliminate extra work. If you insist on using a UserForm (designed in the VBA editor), then you may have to tell us more details about how this form is displayed, what other buttons are there, which one is the default, etc. Your "CommandButton2_Click" routine must be the default button or something. I think a UserForm is more complicated that what you actually need. -- Regards, Bill Renaud |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Forgotten Password to Unprotect Workbook/sheet | Excel Discussion (Misc queries) | |||
How I unprotect my workbook if I failed to remember my password | Excel Worksheet Functions | |||
How do I unprotect a workbook without the password? | Excel Discussion (Misc queries) | |||
Record a macro which enters a password to unprotect a workbook | Excel Programming | |||
Unprotect workbook without password | Excel Programming |