Function To Test If The Workbook Is Protected

less than 1 minute read

Function to test if the workbook is protected.

=============================================================================================
' ## Tests if the activeworkbook is protected
' ' Test if the workbook is protected
' If WorkBookProtected = True Then Exit Sub
'============================================================================================
Function WorkBookProtected() As Boolean With ActiveWorkbook If .ProtectWindows Or .ProtectStructure Then WorkBookProtected = True MsgBox "This workbook is protected" & vbNewline & _ "Cannot continue with this procedure" Exit Function End If End With ' Not protected WorkBookProtected = False
End Function

Tags: developer, function, validation

Categories: vba

Updated: November 16, 2018

Twitter Facebook LinkedIn

Leave a Comment