Kill specific MODULES

M

maperalia

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


'***************************************************************
 
S

Snake Plissken

| On Error Resume Next

deactivate the line listed above and then see what is going on...
 
M

maperalia

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
 
D

Dave Peterson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top