Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default 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
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 another macro Gary McCarthy Excel Discussion (Misc queries) 1 April 21st 09 04:20 PM
Macro warning - how to delete macro GavinS Excel Worksheet Functions 3 April 1st 09 01:45 PM
delete a macro that isn't in macro list Jane Makinson Excel Discussion (Misc queries) 3 March 13th 06 01:10 PM
How can I delete a macro when the Delete button is not active? FCR Excel Worksheet Functions 0 March 9th 06 09:43 AM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM


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

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"