Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Delete a macro using a macro
Hello, I have written a macro to clean my workbook before publishing, and I
would like to delete a macro using this macro. Can someone please help with the code to delete a macro? This won't break the internet will it? |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Delete a macro using a macro
Hi StephenT
Try this if "Trust access to VBA project object model" is checked if the macro is in Module1 Sub RunMacroAndDeletModule() MsgBox "By module1" With ThisWorkbook.VBProject.VBComponents .Remove .Item("Module1") End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "StephenT" wrote in message ... Hello, I have written a macro to clean my workbook before publishing, and I would like to delete a macro using this macro. Can someone please help with the code to delete a macro? This won't break the internet will it? |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Delete a macro using a macro
Thanks Rob
Unfortunately no joy there. The code works if I record a new macro called Module1 (the macro calls itself 'myworksheet.xls'!Module1.Module1). The code then deletes that new module. But if I try to replace the "Module1" with my own macro that I want to delete "deleteme1" then it doesn't work i.e. : Sub RunMacroAndDeletModule() MsgBox "By deleteme1" With ThisWorkbook.VBProject.VBComponents .Remove .Item("deleteme1") End With End Sub Any advice for killing my macro called "deleteme1"? I also have other macros that I don't want deleted at the same time thanks S "Ron de Bruin" wrote: Hi StephenT Try this if "Trust access to VBA project object model" is checked if the macro is in Module1 Sub RunMacroAndDeletModule() MsgBox "By module1" With ThisWorkbook.VBProject.VBComponents .Remove .Item("Module1") End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "StephenT" wrote in message ... Hello, I have written a macro to clean my workbook before publishing, and I would like to delete a macro using this macro. Can someone please help with the code to delete a macro? This won't break the internet will it? |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Delete a macro using a macro
Why not add the macro in a sperate module ?
See this page for delting a macro http://www.cpearson.com/excel/vbe.aspx -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "StephenT" wrote in message ... Thanks Rob Unfortunately no joy there. The code works if I record a new macro called Module1 (the macro calls itself 'myworksheet.xls'!Module1.Module1). The code then deletes that new module. But if I try to replace the "Module1" with my own macro that I want to delete "deleteme1" then it doesn't work i.e. : Sub RunMacroAndDeletModule() MsgBox "By deleteme1" With ThisWorkbook.VBProject.VBComponents .Remove .Item("deleteme1") End With End Sub Any advice for killing my macro called "deleteme1"? I also have other macros that I don't want deleted at the same time thanks S "Ron de Bruin" wrote: Hi StephenT Try this if "Trust access to VBA project object model" is checked if the macro is in Module1 Sub RunMacroAndDeletModule() MsgBox "By module1" With ThisWorkbook.VBProject.VBComponents .Remove .Item("Module1") End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "StephenT" wrote in message ... Hello, I have written a macro to clean my workbook before publishing, and I would like to delete a macro using this macro. Can someone please help with the code to delete a macro? This won't break the internet will it? |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Delete a macro using a macro
Oh I get it... Put all the macros you need to delete in their own module,
then delete the module using your original code. Works now, thanks! "Ron de Bruin" wrote: Why not add the macro in a sperate module ? See this page for delting a macro http://www.cpearson.com/excel/vbe.aspx -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "StephenT" wrote in message ... Thanks Rob Unfortunately no joy there. The code works if I record a new macro called Module1 (the macro calls itself 'myworksheet.xls'!Module1.Module1). The code then deletes that new module. But if I try to replace the "Module1" with my own macro that I want to delete "deleteme1" then it doesn't work i.e. : Sub RunMacroAndDeletModule() MsgBox "By deleteme1" With ThisWorkbook.VBProject.VBComponents .Remove .Item("deleteme1") End With End Sub Any advice for killing my macro called "deleteme1"? I also have other macros that I don't want deleted at the same time thanks S "Ron de Bruin" wrote: Hi StephenT Try this if "Trust access to VBA project object model" is checked if the macro is in Module1 Sub RunMacroAndDeletModule() MsgBox "By module1" With ThisWorkbook.VBProject.VBComponents .Remove .Item("Module1") End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "StephenT" wrote in message ... Hello, I have written a macro to clean my workbook before publishing, and I would like to delete a macro using this macro. Can someone please help with the code to delete a macro? This won't break the internet will it? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro to delete another macro | Excel Discussion (Misc queries) | |||
Macro warning - how to delete macro | Excel Worksheet Functions | |||
delete a macro that isn't in macro list | Excel Discussion (Misc queries) | |||
How can I delete a macro when the Delete button is not active? | Excel Worksheet Functions | |||
How do i delete a macro in Excel 2003 when delete isn't highlight | Excel Discussion (Misc queries) |