ERLANDSEN DATA CONSULTING Excel & VBA Tips   Informasjon på norsk / Information in Norwegian

These pages are no longer updated and are only available for archive purposes.

Click here to visit the pages with updated information.

Check if a VBProject is protected

With the function below you can check if a VBProject is protected before you try to edit the project:

Function ProtectedVBProject(ByVal wb As Workbook) As Boolean
' requires a reference to the Microsoft Visual Basic Extensibility library
' 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
        ProtectedVBProject = False
    End If
End Function


If ProtectedVBProject(ActiveWorkbook) Then Exit Sub


Document last updated 2000-02-05 12:51:07      Printerfriendly version


Erlandsen Data Consulting   
Excel & VBA Tips   Copyright ©1999-2021    Ole P. Erlandsen   All rights reserved
E-mail Contact Address