아래 함수를 사용하여 프로젝트를 편집하기 전에 VBProject가 보호되는지 확인할 수 있습니다.

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

예 :

If ProtectedVBProject(ActiveWorkbook) Then Exit Sub