I have code that will delete the modules
(I remove the modules and protect the worksheet when I send the final
report for distribution),
but how do you plan to determine the failed password attempts?
Plus, what good is it to delete a single module?
Once one or more modules are removed, won't execution results become
unpredictable? If the person fat-fingers the password the first time,
but corrects his mistake the second, he'll be missing a module and
probably needs to start over anyway...
Well.. if you can figure out the failed password, here is what I use:
Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents
For Each VBComp In VBComps
'MsgBox VBComp.name
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp