Scottflyer
IS-IT--Management
Hi:
I want to protect and unprotect -- with password from a VBA subroutine or function. I'm currently using the following code, but it only works if the VBA Project is open or unprotected, which doesn't serve my purpose:
Set VBP = ActiveWorkbook.VBProject
If ActiveWorkbook.VBProject.Protection = vbext_pp_locked Then
SendKeys "~" & MdP & "~", True
End If
With VBP.VBComponents
.Remove VBP.VBComponents("Module3"
.Remove VBP.VBComponents("Module5"
End With
I'd prefer to unprotect the project with code, do several operations on modules, like .Export, .Import, .Remove to do a software update for example, etc. and then protect the project at the end of the code. I don't know the method(s) for VBA Project protection and unprotection and the way the password is passed to them [Excel in Office XP]. If anyone can help. Thanks very much!!
Scottflyer
I want to protect and unprotect -- with password from a VBA subroutine or function. I'm currently using the following code, but it only works if the VBA Project is open or unprotected, which doesn't serve my purpose:
Set VBP = ActiveWorkbook.VBProject
If ActiveWorkbook.VBProject.Protection = vbext_pp_locked Then
SendKeys "~" & MdP & "~", True
End If
With VBP.VBComponents
.Remove VBP.VBComponents("Module3"
.Remove VBP.VBComponents("Module5"
End With
I'd prefer to unprotect the project with code, do several operations on modules, like .Export, .Import, .Remove to do a software update for example, etc. and then protect the project at the end of the code. I don't know the method(s) for VBA Project protection and unprotection and the way the password is passed to them [Excel in Office XP]. If anyone can help. Thanks very much!!
Scottflyer