Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Delete Modules in Macro

The macro recorder does not record the mouse clicks to Delete a Module.

How can I delete modules via a macro?

Thanks,
Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Delete Modules in Macro

Visit Chip Pearson's site to find out how:
http://www.cpearson.com/excel/vbe.htm

Mark wrote:

The macro recorder does not record the mouse clicks to Delete a Module.

How can I delete modules via a macro?

Thanks,
Mark


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete Modules in Macro

Mark,

Here is an example for Module2

Dim VBComp As Object

Set VBComp = ThisWorkbook.VBProject.vbcomponents("Module2")
ThisWorkbook.VBProject.vbcomponents.Remove VBComp

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mark" wrote in message
...
The macro recorder does not record the mouse clicks to Delete a Module.

How can I delete modules via a macro?

Thanks,
Mark



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Delete Modules in Macro

I'd like to remove all the modules in a workbook.

Would you have some sample code to iterate through the modules within a
workbook?

Thank you - your posts are very helpful.

Mark

"Bob Phillips" wrote:

Mark,

Here is an example for Module2

Dim VBComp As Object

Set VBComp = ThisWorkbook.VBProject.vbcomponents("Module2")
ThisWorkbook.VBProject.vbcomponents.Remove VBComp

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mark" wrote in message
...
The macro recorder does not record the mouse clicks to Delete a Module.

How can I delete modules via a macro?

Thanks,
Mark




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete Modules in Macro

Mark,

This will remove all modules. You cannot remove Sheet or Thisworkbook
modules.

Dim VBComp As Object
Dim vbMod As Object

For Each vbMod In ThisWorkbook.VBProject.vbcomponents
If vbMod.Type = 1 Then ' a module
ThisWorkbook.VBProject.vbcomponents.remove vbMod
End If
Next vbMod


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mark" wrote in message
...
I'd like to remove all the modules in a workbook.

Would you have some sample code to iterate through the modules within a
workbook?

Thank you - your posts are very helpful.

Mark

"Bob Phillips" wrote:

Mark,

Here is an example for Module2

Dim VBComp As Object

Set VBComp = ThisWorkbook.VBProject.vbcomponents("Module2")
ThisWorkbook.VBProject.vbcomponents.Remove VBComp

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mark" wrote in message
...
The macro recorder does not record the mouse clicks to Delete a

Module.

How can I delete modules via a macro?

Thanks,
Mark






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
Visual Basic Protection and Delete Modules Jeremy Excel Discussion (Misc queries) 3 April 27th 10 02:32 PM
Delete Code Modules Programatically blatham Excel Discussion (Misc queries) 1 February 3rd 06 05:38 PM
When to code in sheet or userform modules and when to use modules Tony James Excel Programming 1 December 16th 04 10:02 PM
Delete modules programmatically and save Brijesh Shah Excel Programming 3 December 24th 03 08:14 PM
Delete Modules and Userforms Peter Pantus Excel Programming 1 September 26th 03 08:17 PM


All times are GMT +1. The time now is 05:28 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"