Kill specific MODULES

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this statement to kill two modules (see below). However, for some
reason these modules are not deleted after the macro is run.

Could you please check it and help me to make it run.

Thanks in advance.
Maperalia.
P.D. This statement is located in the "Module 2"
'***************************************************************
'KILL TWO MODULES
Dim VBComp As VBComponent
Dim VBComp1 As VBComponent
Application.ScreenUpdating = False

Waiting_Message.Repaint
On Error Resume Next
Set VBComp = ActiveWorkbook.VBProject.VBComponents("Module2")
ActiveWorkbook.VBProject.VBComponents.Remove VBComp


Waiting_Message.Repaint

Set VBComp1 = ActiveWorkbook.VBProject.VBComponents("Module7")
ActiveWorkbook.VBProject.VBComponents.Remove VBComp1
On Error GoTo 0


'***************************************************************
 
| On Error Resume Next

deactivate the line listed above and then see what is going on...
 
Snake;
Thanks for your quick response.
I desactivate the lien you advised me and I got the following error message:
RUN-TIME ERROR '1004'
PROGRAMMATIC ACCESS TO VUIUAL BASIC PROJECT IS NOT TRUSTED.
Then isit is highligthing the following line:
Set VBComp = ActiveWorkbook.VBProject.VBComponents("Module2")

What do you think?.

Maperalia
 
Excel offers different levels of protection to the user--including not allowing
macros to change other macros.

You can toggle this setting by:
Tools|Macro|Security|Trusted Publisher tab
check Trust access to Visual Basic Project

If you're sharing this code with others, be aware that this is a user setting.
Each user has to change it for themself.
 
Back
Top