Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default Protection Property

I need to systematically determine if a worksheet is protected or not, so
then I can create the if statement to do some events if the worksheet is
protected and other events if it is not protected.

I thought I would be able to do so via the worksheets properties, but am now
very confused.

ANy and All Help Is Appreciated - Thank You
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Protection Property

I am not too sure which level of protection you need to catch (probably
contents) but here is a function...

Sub TestProtection()
MsgBox IsProtected(Sheet1)
MsgBox IsProtected(Sheet2)

End Sub

Public Function IsProtected(ByVal wks As Worksheet) As Boolean

If wks.ProtectContents = True Or _
wks.ProtectDrawingObjects = True Or _
wks.ProtectScenarios = True Then
IsProtected = True
Else
IsProtected = False
End If

End Function
--
HTH...

Jim Thomlinson


"MWS" wrote:

I need to systematically determine if a worksheet is protected or not, so
then I can create the if statement to do some events if the worksheet is
protected and other events if it is not protected.

I thought I would be able to do so via the worksheets properties, but am now
very confused.

ANy and All Help Is Appreciated - Thank You

  #3   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default Protection Property

Thank You Jim - I Appreciate Your Help!!!!

"Jim Thomlinson" wrote:

I am not too sure which level of protection you need to catch (probably
contents) but here is a function...

Sub TestProtection()
MsgBox IsProtected(Sheet1)
MsgBox IsProtected(Sheet2)

End Sub

Public Function IsProtected(ByVal wks As Worksheet) As Boolean

If wks.ProtectContents = True Or _
wks.ProtectDrawingObjects = True Or _
wks.ProtectScenarios = True Then
IsProtected = True
Else
IsProtected = False
End If

End Function
--
HTH...

Jim Thomlinson


"MWS" wrote:

I need to systematically determine if a worksheet is protected or not, so
then I can create the if statement to do some events if the worksheet is
protected and other events if it is not protected.

I thought I would be able to do so via the worksheets properties, but am now
very confused.

ANy and All Help Is Appreciated - Thank You

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
Runtime Error 380 – Could not set the list property. Invalid property value BernzG[_16_] Excel Programming 2 August 21st 05 10:10 PM
Protection property of the VBA project helmekki[_89_] Excel Programming 3 August 10th 05 01:18 AM
Runtime error 380: Could not set the List property. invalid property value of listbox jasgrand Excel Programming 0 October 6th 04 09:28 PM
Is there a Filename property in PrintOut property Christian[_6_] Excel Programming 4 September 3rd 04 10:12 PM
Worksheet/workbook protection property? brian Excel Programming 1 July 14th 03 07:43 PM


All times are GMT +1. The time now is 06:49 PM.

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"