G
Guest
I am reposting the same concern with a try to explain it in better way
I have a template which i need to distribute to unknown number of audiance. I need to delete all the code (forms, modules etc) after my output is done (Main Reson : Size, and code + data security). I am using the below code to do that but If "Programmatic access to Visual Basic Project is not trusted" is not checked manually, i get the following error : Programmatic access to Visual Basic Project is not trusted, "Runtime error 1004
Is there anyway that I can set the option under: "Tools, Macro, Security...Trust access to Visual Basic Project" through my VBA code.
Sub DeleteALLVBA(
Dim VBComp As VBIDE.VBComponen
Dim VBComps As VBIDE.VBComponent
Set VBComps = ActiveWorkbook.VBProject.VBComponent
For Each VBComp In VBComp
Select Case VBComp.Typ
Case vbext_ct_StdModule, vbext_ct_MSForm, vbext_ct_ClassModul
VBComps.Remove VBCom
Case Els
With VBComp.CodeModul
.DeleteLines 1, .CountOfLine
End Wit
End Selec
Next VBCom
End Su
I have a template which i need to distribute to unknown number of audiance. I need to delete all the code (forms, modules etc) after my output is done (Main Reson : Size, and code + data security). I am using the below code to do that but If "Programmatic access to Visual Basic Project is not trusted" is not checked manually, i get the following error : Programmatic access to Visual Basic Project is not trusted, "Runtime error 1004
Is there anyway that I can set the option under: "Tools, Macro, Security...Trust access to Visual Basic Project" through my VBA code.
Sub DeleteALLVBA(
Dim VBComp As VBIDE.VBComponen
Dim VBComps As VBIDE.VBComponent
Set VBComps = ActiveWorkbook.VBProject.VBComponent
For Each VBComp In VBComp
Select Case VBComp.Typ
Case vbext_ct_StdModule, vbext_ct_MSForm, vbext_ct_ClassModul
VBComps.Remove VBCom
Case Els
With VBComp.CodeModul
.DeleteLines 1, .CountOfLine
End Wit
End Selec
Next VBCom
End Su