Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Test if protected

How do you tell if the active file workbook protect is activated? For Sheet
protect test I have used:

If ActiveSheet.ProtectContents = True Then ............

For the Workbook I tried:

If ActiveWorkbook.ProtectContents = True Then ..........

But that does not work.

Thanks for your help,

Steven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Test if protected

Just run

ActiveWorkbook.Protect Contents:= true
or
ActiveWorkbook.Protect Contents:= true password:= "passkey"

then you know it is.

and

ActiveWorkbook.Unprotect
or
ActiveWorkbook.Unprotect Password:= "passkey"

when you need to unprotect it.

Do you really need to query the status?
You could try to change the value of a cell you know should be locked
and intercept the error if Protection is enabled.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Test if protected

This works too and can be modified to check different criteria;

Sub CheckProtection()

ActiveSheet.Protect

' Check the ability to insert columns on a protected sheet.
' Notify the user of this status.
If ActiveSheet.Protection.AllowInsertingColumns = True Then
MsgBox "The insertion of columns is allowed on this protected
worksheet."
Else
MsgBox "The insertion of columns is not allowed on this
protected worksheet."
End If

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Test if protected

Steven,

If ActiveWorkbook.ProtectStructure Or
ActiveWorkbook.ProtectWindows Then
Debug.Print "workbook is protected"
Else
Debug.Print "workbook not protected"
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Steven" wrote in message
...
How do you tell if the active file workbook protect is
activated? For Sheet
protect test I have used:

If ActiveSheet.ProtectContents = True Then ............

For the Workbook I tried:

If ActiveWorkbook.ProtectContents = True Then ..........

But that does not work.

Thanks for your help,

Steven



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
Edit text format in non-protected cells in protected worksheet Bonnie Excel Discussion (Misc queries) 2 April 19th 08 04:48 PM
Calculate mean of test scores from rows of test answers RiotLoadTime Excel Discussion (Misc queries) 1 July 26th 06 05:14 PM
Group, Outline, Protected Worksheets and Protected Workbook BEEJAY Excel Programming 0 February 13th 06 08:40 PM
test..where are my messages..test HT New Users to Excel 0 January 23rd 05 06:23 PM
Copy of protected document was unprotected in 97 and protected in 2002 Beth Mantoan Excel Programming 0 July 31st 03 10:40 PM


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