![]() |
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 |
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. |
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 |
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 |
All times are GMT +1. The time now is 01:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com