ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   VBA, delete all macro (https://www.excelbanter.com/excel-worksheet-functions/67621-vba-delete-all-macro.html)

Danny

VBA, delete all macro
 
Hi,

I have 3 macros in 1 module and 1 macro (before print) in the
"ThisWorkbook". Is there a way to delete all the macros automatically (with a
macro?!) in a workbook?

Thank you.

Ron de Bruin

VBA, delete all macro
 
Hi Danny

Copy this macro in Module1
If you run it it delete the whole module

Add code to delete the code in the thisworkbook where it say

'
' your code
'

See Chip's site
http://www.cpearson.com/excel/vbe.htm


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





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


"Danny" wrote in message ...
Hi,

I have 3 macros in 1 module and 1 macro (before print) in the
"ThisWorkbook". Is there a way to delete all the macros automatically (with a
macro?!) in a workbook?

Thank you.




Chip Pearson

VBA, delete all macro
 
Danny,

Try

With ActiveWorkbook.VBProject.VBComponents
.Remove .Item("Module1")
With .Item("ThisWorkbook").CodeModule
.DeleteLines 1, .CountOfLines
End With
End With

See www.cpearson.com/excel/vbe.htm for more info and examples.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Danny" wrote in message
...
Hi,

I have 3 macros in 1 module and 1 macro (before print) in the
"ThisWorkbook". Is there a way to delete all the macros
automatically (with a
macro?!) in a workbook?

Thank you.




Danny

VBA, delete all macro
 
Gentlemen:

Thanks a lot. Have a great weekend!

Regards,
Danny

"Chip Pearson" wrote:

Danny,

Try

With ActiveWorkbook.VBProject.VBComponents
.Remove .Item("Module1")
With .Item("ThisWorkbook").CodeModule
.DeleteLines 1, .CountOfLines
End With
End With

See www.cpearson.com/excel/vbe.htm for more info and examples.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Danny" wrote in message
...
Hi,

I have 3 macros in 1 module and 1 macro (before print) in the
"ThisWorkbook". Is there a way to delete all the macros
automatically (with a
macro?!) in a workbook?

Thank you.






All times are GMT +1. The time now is 07:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com