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: 4
Default unprotect sheet failure

I'm using the code below to switch between a development enviroment, where I
can view private data and change anything I want to on a sheet, and a user
environment where private data is hidden and the user interface is
protected.

It works, EXCEPT for whatever happens to be the active sheet when I invoke
the macro.

Thanks In Advance!
Eric

Public Sub ProtectAllSheets(protectionLevel As ProtectionOptions)
On Error GoTo ProtectAllSheets_Error

Dim wks As Worksheet
For Each wks In ActiveWorkbook.Sheets
Select Case protectionLevel
Case Protect
Call wks.Protect(UserInterfaceOnly:=False, Password:=pWord)
Case Unprotect
Call wks.Unprotect(pWord)
End Select
Next wks

On Error GoTo 0
Exit Sub

ProtectAllSheets_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
ProtectAllSheets of Module MSecurity"

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
vlookup failure & ctrl-f failure? joemeshuggah Excel Discussion (Misc queries) 4 December 22nd 08 07:22 PM
Ctrl+Home failure when sheet protected Drew[_2_] Excel Discussion (Misc queries) 1 March 19th 08 06:18 AM
Copying objects to new sheet failure Steven Excel Discussion (Misc queries) 0 July 25th 07 02:50 PM
Chart versus Work Sheet Code Failure Nigel Excel Programming 2 April 18th 05 05:16 PM
unprotect sheet in code and make sheet visible peach255 Excel Programming 1 August 1st 03 03:28 AM


All times are GMT +1. The time now is 09:26 AM.

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

About Us

"It's about Microsoft Excel"