+ Reply to Thread
Results 1 to 3 of 3

Checking Worksheet Protect Stage

Hybrid View

gabch Checking Worksheet Protect... 01-03-2007, 09:18 PM
jetted hi I amended the code from... 01-04-2007, 11:47 AM
jetted hi I have amended quickly... 01-04-2007, 11:50 AM
  1. #1
    Registered User
    Join Date
    01-20-2006
    Posts
    68

    Checking Worksheet Protect Stage

    Hi,

    Checking the worksheet protect stage is Activesheet.protectcontects
    How can I check the protect with Userinterfaceonly stage?

    Thx

  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    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)

  3. #3
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1