Note: I am note trying to use this information for hacking. The company I work for is making us protect all our macros. We have thousands and I don't want to have to go into each one to see if it is protected.
Using vba in excel, I want to be able to test if the vba password is set. Using the below function I can tell most of the time. The only problem is if the "Lock project for viewing" isn't checked and a password is set, the below function will say it isn't protected but when you try to go into the properties it prompts you for a password. Is there a way to tell if it is protected even if they didn't check "Lock project for viewing"?
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