|
Re: How to program a code to die
Hi davidm, this may be something you are looking for..found after a
quick search
of this ng.... Be careful with it... it will delete all the code you
have written.
Option Explicit
Public Sub DeleteAllVBA()
Dim vbComp As Object
For Each vbComp In ActiveWorkbook.VBProject.VBComponents
With vbComp
If .Type = 100 Then
.CodeModule.DeleteLines 1, .CodeModule.CountOfLines
Else
ActiveWorkbook.VBProject.VBComponents.Remove vbComp
End If
End With
Next vbComp
End Sub
Public Sub DeleteAllVBA()
For Each book In Workbooks
If book.Name <> ThisWorkbook.Name Then
Dim vbComp As Object
For Each vbComp In ActiveWorkbook.VBProject.VBComponents
With vbComp
If .Type = 100 Then
..CodeModule.DeleteLines 1, .CodeModule.CountOfLines
Else
ActiveWorkbook.VBProject.VBComponents.Remove vbComp
End If
End With
Next vbComp
End If
Next book
End Sub
Here'a another one you may want to play with, as you can pick the
module to delete
Sub deletemodule()
MsgBox "place your code here"
With ThisWorkbook.VBProject.VBComponents
.Remove .Item("Module1")
End With
End Sub
Hope these help
ste
davidm wrote:
> I am following up on my post which seems to have slipped out of traffic.
> Thanks in advance of any help.
>
> David
>
>
> --
> davidm
> ------------------------------------------------------------------------
> davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
> View this thread: http://www.excelforum.com/showthread...hreadid=480988
|