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: 9
Default Unprotecting sheet did not prompt for password

I have automated sheets to be protected by a global variable g_mStrPW.
However, when trying to unprotect individual sheet, the sheet gets
unprotected without prompting for password. This is bad and made protecting
sheets meaningless.

Here is the code used to protect all sheets.

Private Sub LockEM_Click()
Dim i As Long
Dim WS As Worksheet
g_mStrPW = InputBox("Password:")

On Error GoTo MyErr
For Each WS In ActiveWorkbook.Worksheets
WS.Protect (g_mStrPW)
If WS.Protection.AllowUsingPivotTables = False Then
WS.Protect AllowUsingPivotTables:=True
WS.Protect AllowFiltering:=True
End If
Next
MsgBox i & " errors found", vbInformation

Exit Sub
MyErr:
i = i + 1
Resume Next
End Sub
 
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 asking for a password twice when unprotecting sheet Tim Whitley[_3_] Excel Programming 2 February 20th 06 04:51 PM
Password Protecting/Unprotecting Via Code MWS Excel Programming 3 December 12th 05 03:21 PM
Unprotecting password protected workbook Vnagpal Excel Discussion (Misc queries) 1 December 10th 05 06:33 AM
password prompt to unhide sheet Jeff Excel Programming 1 June 9th 04 08:40 PM
Simple password function - unprotecting sheets Peter Hill Excel Programming 4 September 24th 03 03:38 AM


All times are GMT +1. The time now is 02:02 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"