Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I tried to record a macro being deleted and nothing recorded.
|
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I posted an explanation of a way to do this in this message:
http://www.mrexcel.com/forum/showthr...elf-destruct#3 -- "Actually, I *am* a rocket scientist." -- JB Your feedback is appreciated, click YES if this post helped you. "Fan924" wrote: I tried to record a macro being deleted and nothing recorded. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Be careful how you use this, there's no going back if you save the workbook. This code can delete the module it's in (a sort of code suicide) or run from another module delete that one. Chane the last line to the name of the module to delete. Sub Death_To_Code() Dim ThisModule As Object Set ThisModule = Application.VBE.ActiveVBProject.VBComponents ThisModule.Remove VBComponent:=ThisModule.Item("Module2") End Sub Mike "Fan924" wrote: I tried to record a macro being deleted and nothing recorded. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I found this from 2000
Sub OpenFileAndDeleteModule() Application.ScreenUpdating = False Workbooks.Open "C:\Excel\book1.xls" With ActiveWorkbook.VBProject .VBComponents.Remove .VBComponents("Module1") End With ActiveWorkbook.Save ActiveWorkbook.Close End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have been playing with this. From the archives. Deletes all macros.
Sometimes it deletes itself, sometimes it does not.Can it be fixed so it always deletes itself? Sub DeleteAllMacros() Dim Composantvbe As Object With ThisWorkbook.VBProject For Each Composantvbe In .VBComponents If Composantvbe.Type = 100 Then With Composantvbe.CodeModule .DeleteLines 1, .CountOfLines .CodePane.Window.Close End With Else: .VBComponents.Remove Composantvbe End If Next Composantvbe ActiveWorkbook.Save ActiveWorkbook.Close End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Macro Security Problem - Trusted macros not running for users (but do run for domain admins) | Excel Programming | |||
Running Macros | Links and Linking in Excel | |||
How to stop file open macro prompt after deleting all macros? | Excel Worksheet Functions | |||
macro warning persists even after deleting all macros | Excel Discussion (Misc queries) | |||
Running Macros | Excel Programming |