Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
test sheet for protection
Been racking my brains again...
Tried: On Error Resume Next If Not ActiveSheet.Protection Is Nothing Then MsgBox "sheet is protected" Else: MsgBox "Sheet is not protected" On Error GoTo 0 End If ....but alas, no joy, please help |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
test sheet for protection
You were nearly there, try this:-
Sub isitprotected() If ActiveSheet.ProtectContents = True Then MsgBox ("Protected") Else MsgBox ("Unprotected") End If End Sub Mike "David" wrote: Been racking my brains again... Tried: On Error Resume Next If Not ActiveSheet.Protection Is Nothing Then MsgBox "sheet is protected" Else: MsgBox "Sheet is not protected" On Error GoTo 0 End If ...but alas, no joy, please help |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
test sheet for protection
excellent! Thank you
"Mike" wrote: You were nearly there, try this:- Sub isitprotected() If ActiveSheet.ProtectContents = True Then MsgBox ("Protected") Else MsgBox ("Unprotected") End If End Sub Mike "David" wrote: Been racking my brains again... Tried: On Error Resume Next If Not ActiveSheet.Protection Is Nothing Then MsgBox "sheet is protected" Else: MsgBox "Sheet is not protected" On Error GoTo 0 End If ...but alas, no joy, please help |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
test sheet for protection
I put this code in the Workbook BeforeClose Event to make sure the Sheet is
protected before I close the App. Works perfectly when I try to close the app using the Close Button at top right of the window. When I close the App using the code Application.Quit in a close button I put into a form, ActiveSheet.ProtectContents is always False. If I use Sheets("name").ProtectContents, same thing always False. Does that make sense, is there a work around? "Mike" wrote: You were nearly there, try this:- Sub isitprotected() If ActiveSheet.ProtectContents = True Then MsgBox ("Protected") Else MsgBox ("Unprotected") End If End Sub Mike "David" wrote: Been racking my brains again... Tried: On Error Resume Next If Not ActiveSheet.Protection Is Nothing Then MsgBox "sheet is protected" Else: MsgBox "Sheet is not protected" On Error GoTo 0 End If ...but alas, no joy, please help |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
test sheet for protection
David,
Check the ProtectContents property: If ActiveSheet.ProtectContents Then MsgBox "sheet is protected" Else MsgBox "Sheet is not protected" End If -- Hope that helps. Vergel Adriano "David" wrote: Been racking my brains again... Tried: On Error Resume Next If Not ActiveSheet.Protection Is Nothing Then MsgBox "sheet is protected" Else: MsgBox "Sheet is not protected" On Error GoTo 0 End If ...but alas, no joy, please help |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
test sheet for protection
Excellent! Thank you
"Vergel Adriano" wrote: David, Check the ProtectContents property: If ActiveSheet.ProtectContents Then MsgBox "sheet is protected" Else MsgBox "Sheet is not protected" End If -- Hope that helps. Vergel Adriano "David" wrote: Been racking my brains again... Tried: On Error Resume Next If Not ActiveSheet.Protection Is Nothing Then MsgBox "sheet is protected" Else: MsgBox "Sheet is not protected" On Error GoTo 0 End If ...but alas, no joy, please help |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
test sheet for protection
There are different levels of protection...
Option Explicit sub testme() msgbox wksisprotected(activesheet) end sub Function WksIsProtected(wks As Worksheet) As Boolean If wks.ProtectContents = True _ Or wks.ProtectDrawingObjects = True _ Or wks.ProtectScenarios = True Then WksIsProtected = True Else WksIsProtected = False End If End Function David wrote: Been racking my brains again... Tried: On Error Resume Next If Not ActiveSheet.Protection Is Nothing Then MsgBox "sheet is protected" Else: MsgBox "Sheet is not protected" On Error GoTo 0 End If ...but alas, no joy, please help -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel Data Protection Best Practice: AKA: Real Sheet Protection | Excel Discussion (Misc queries) | |||
Excel Data Protection- AKA: Sheet/Macro Password Protection | Setting up and Configuration of Excel | |||
Macro protection - How to test Windows registration infos | Excel Programming | |||
How to test to see if a given sheet from is in a workbook from ano | Excel Programming | |||
Sheet protection error msg - Unrequested sheet activation | Excel Programming |