» 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:
question
wayne Posted on: 31-12-1969
could that format be used to set the property to -1 (locked) ?Protecting Excel
Phil Posted on: 31-12-1969
Hi, I simply want to protect my VBA code in Excel from people. They must still be able to use the worksheets as they see fit but not see my code. Anyone know how I do this?
If your reply is password protection, how do I do that? I also understand that a determined hacker could probaly get to the code anyway.


