» Check if a VBProject is protected using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Protecting in VBA
VERSION - All Microsoft Excel Versions
Function ProtectedVBProject(ByVal wb As Workbook) As Boolean
' returns TRUE if the VB project in the active document is protected
Dim VBC As Integer
VBC = -1
On Error Resume Next
VBC = wb.VBProject.VBComponents.Count
On Error GoTo 0
If VBC = -1 Then
ProtectedVBProject = True
Else
ProtectedVBProject = False
End If
End Function
Example:
If ProtectedVBProject(ActiveWorkbook) Then Exit Sub
Book Store:
Recommended Books:
- The Essential 55: An Award-Winning Educator's Rules for Discovering the Successful Student in Every Child
- Positioning: The Battle for Your Mind
- Cashflow Quadrant: Rich Dad's Guide to Financial Freedom
- Microsoft Office XP Step-By-Step (With CD-ROM)
- The Financial Numbers Game: Detecting Creative Accounting Practices
- Accounting the Easy Way
No comments have been submitted.

