Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Excel Data Protection Best Practice: AKA: Real Sheet Protection Mushman(Woof!)[_2_] Excel Discussion (Misc queries) 4 December 30th 09 01:20 AM
Excel Data Protection- AKA: Sheet/Macro Password Protection Mushman(Woof!) Setting up and Configuration of Excel 0 December 29th 09 06:50 AM
Macro protection - How to test Windows registration infos Alex St-Pierre Excel Programming 3 March 10th 07 02:37 AM
How to test to see if a given sheet from is in a workbook from ano dajns Excel Programming 8 March 27th 06 10:20 PM
Sheet protection error msg - Unrequested sheet activation deltree[_3_] Excel Programming 0 January 28th 04 06:20 PM


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