LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Macro to prompt for password to unprotect worksheets

I've got the following vb code in an Excel macro to unprotect all worksheets
in a document:

Sub UnprotectAllSheets()

Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Worksheets.Count
Worksheets(n).Unprotect Password:="password"
Next n
Application.ScreenUpdating = True

End Sub

The code is attached to a command button on the first worksheet. When the
button is selected, I'd like a prompt to appear to ask the user to input the
relevant password. If the password entered does not match what has been
specified in the code, the sheets cannot be unprotected. How can I do this?

Also, is there any way of disabling the sheet protection option on the menu
bar: Tools\Protection\Unprotect Sheet?

Many thanks in advance.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to protect/unprotect with password Cam Excel Programming 3 July 26th 05 10:36 PM
Password Applied to All Worksheets Confrimation Prompt snsd[_7_] Excel Programming 0 November 13th 04 08:01 PM
Password Applied to All Worksheets Confrimation Prompt snsd[_6_] Excel Programming 2 November 12th 04 07:27 PM
Protecting Multiple sheets with prompt for password to unprotect pkley Excel Programming 1 January 10th 04 06:46 AM
unprotect more than one password in macro Morticcia Excel Programming 1 October 1st 03 04:55 PM


All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"