Hi,
Checking the worksheet protect stage is Activesheet.protectcontects
How can I check the protect with Userinterfaceonly stage?
Thx
Hi,
Checking the worksheet protect stage is Activesheet.protectcontects
How can I check the protect with Userinterfaceonly stage?
Thx
hi
I amended the code from http://www.vbaexpress.com/kb/getarticle.php?kb_id=551
![]()
Option Explicit Public Function wbSheetsProtected(wbTarget As Workbook) As Boolean 'Macro created 07/08/2005 22:12 by Ken Puls 'Macro Purpose: To test if any worksheet in the workbook is protected ' Returns False if no sheets protected ' Returns True if one or more sheets protected Dim ws As Worksheet 'Set function to False wbSheetsProtected = False 'Loop through each worksheet and check for protection For Each ws In wbTarget.Worksheets If ws.ProtectContents = True Then 'If protected, set function to True and exit MsgBox ws.Name & " is proctected" Else MsgBox ws.Name & " is unproctected" End If Next ws End Function Sub CheckProtection() 'Macro created 07/08/2005 22:14 by Ken Puls 'Macro Purpose: To test the wbSheetsProtected function If wbSheetsProtected(ThisWorkbook) = True Then Else End If End Sub
Denis![]()
Please always attach the sample workbook without sensitive information when asking for help
To add a module
Press Alt + F11 (this is the Visual Basic Environment)
Insert Menu, select Module
Past code there
Close Visual Basic Environment (X)
hi
I have amended quickly the code from http://www.vbaexpress.com/kb/getarticle.php?kb_id=551
![]()
Option Explicit Public Function wbSheetsProtected(wbTarget As Workbook) As Boolean 'Macro created 07/08/2005 22:12 by Ken Puls 'Macro Purpose: To test if any worksheet in the workbook is protected ' Returns False if no sheets protected ' Returns True if one or more sheets protected Dim ws As Worksheet 'Set function to False wbSheetsProtected = False 'Loop through each worksheet and check for protection For Each ws In wbTarget.Worksheets If ws.ProtectContents = True Then 'If protected, set function to True and exit MsgBox ws.Name & " is proctected" Else MsgBox ws.Name & " is unproctected" End If Next ws End Function Sub CheckProtection() 'Macro created 07/08/2005 22:14 by Ken Puls 'Macro Purpose: To test the wbSheetsProtected function If wbSheetsProtected(ThisWorkbook) = True Then Else End If End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks