Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
mdb mdb is offline
external usenet poster
 
Posts: 1
Default Can a macro delete itself (and others)?

From an Excel VBA app (running as an excel macro) is it possible to delete
the macro and all other macros, while the present macro is running? If so,
how?


--
-mdb
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Can a macro delete itself (and others)?

Hi MDB,

See ChipPearson at:

http://www.cpearson.com/excel/vbe.htm

And, previously posted by Chip:

Sub SelfDestruct()

Dim VBCodeMod As CodeModule
Dim StartLine As Long
Dim HowManyLines As Long

Set VBCodeMod = ThisWorkbook.VBProject. _
VBComponents("NewModule").CodeModule
With VBCodeMod
StartLine = .ProcStartLine("SelfDestruct", vbext_pk_Proc)
HowManyLines = .ProcCountLines("SelfDestruct", vbext_pk_Proc)
.DeleteLines StartLine, HowManyLines
End With

End Sub


---
Regards,
Norman



"mdb" <m_b_r_a_y@c_t_i_u_s_a__d0t__com wrote in message
. ..
From an Excel VBA app (running as an excel macro) is it possible to delete
the macro and all other macros, while the present macro is running? If
so,
how?


--
-mdb



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Can a macro delete itself (and others)?

See
http://www.cpearson.com/excel/vbe.htm

Here is example

With One macro named "TheMacro" in Module1
The simplest way is to delete the entire module with contains the procedure.

Sub TheMacro()
'
' your code
'
With ThisWorkbook.VBProject.VBCompo*nents
.Remove .Item("Module1")
End With
End Sub

But this must be checked to do this
http://www.j-walk.com/ss/excel/tips/tip96.htm



--
Regards Ron de Bruin
http://www.rondebruin.nl


"mdb" <m_b_r_a_y@c_t_i_u_s_a__d0t__com wrote in message . ..
From an Excel VBA app (running as an excel macro) is it possible to delete
the macro and all other macros, while the present macro is running? If so,
how?


--
-mdb



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Can a macro delete itself (and others)?

That stupid Google Beta<g

Note the - in the code in y other reply

Sub TheMacro()
'
' your code
'
With ThisWorkbook.VBProject.VBComponents
.Remove .Item("Module1")
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ron de Bruin" wrote in message ...
See
http://www.cpearson.com/excel/vbe.htm

Here is example

With One macro named "TheMacro" in Module1
The simplest way is to delete the entire module with contains the procedure.

Sub TheMacro()
'
' your code
'
With ThisWorkbook.VBProject.VBCompo*nents
.Remove .Item("Module1")
End With
End Sub

But this must be checked to do this
http://www.j-walk.com/ss/excel/tips/tip96.htm



--
Regards Ron de Bruin
http://www.rondebruin.nl


"mdb" <m_b_r_a_y@c_t_i_u_s_a__d0t__com wrote in message . ..
From an Excel VBA app (running as an excel macro) is it possible to delete
the macro and all other macros, while the present macro is running? If so,
how?


--
-mdb





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 04:38 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:20 PM


All times are GMT +1. The time now is 08:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"