View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Jeff W. Jeff W. is offline
external usenet poster
 
Posts: 38
Default Can I Delete A Module On Exit?

Even if I put thisw in Module2 and run it from the macro menu
it stops on the first line and says; (Compile Error)

Sub DeleteAllVBACode()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule

Set VBProj = ActiveWorkbook.VBProject

For Each VBComp In VBProj.VBComponents
If VBComp.Type = vbext_ct_Document Then
Set CodeMod = VBComp.CodeModule
With CodeMod
.DeleteLines 1, .CountOfLines
End With
Else
VBProj.VBComponents.Remove VBComp
End If
Next VBComp
End Sub



Maybe this would be easier if I could just have something like;

if (A11) doesnt equal blank then run sub
else dont run sub

I know this is all wrong on syntax but its what should happen

Does this make more sence?

<Jeff


"Myrna Larson" wrote in message
...
Did you replace the placeholder modulename with the actual name of the
module
-- in quotes if it's a literal ??

On Wed, 31 Oct 2007 15:35:51 -0500, "Jeff W."
wrote:

Bob, I'm not sure I have put this in correctly,
I get a compile error in hidden module

I have an auto run macro that calls another sub to run and
I have put this at the bottom of the second sub


not sure if this is right, but it doesnt want to work.

the debugger hanfs on the SET part of the additional code

<Jeff




"Bob Phillips" wrote in message
...
Dim vbMod As Object

Set vbMod = ActiveWorkbook.VBProject.VBComponents(moduleName)
ThisWorkbook.VBProject.VBComponents.Remove vbMod


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Jeff W." wrote in message
...
I have a work book that gets copied and renamed by another application
and when it runs it automatically fills with data, and I would like to
make
it so after you close and reopen, it doesnt try to auto run again.

Is this possible? I guess I want to delete all autorun macros on exit?


Thanks

Jeff W.