• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Workbook Save as (With Selected Modules) Not All Macro Modules

AAP

Member
Hello Everyone, I have a workbook that contains two macros(modules), When I run Macro-1/module-1 it does the things I like and finally save as another workbook at the destination. What I want is when it save into new workbook only Macro-2/module-2 can save not Macro-1/module-1 into new workbook. Is there any suggestion around this problem or any alternative. Many thanks in advance for your precious advice on this problem.

Regards/Amit
 
Hi Deepak, does code has something to do with it. Because what I want is when I save a new workbook only module2 can copy/go with new book not module1.

Regards/Amit
 
Hi Deepak, does code has something to do with it. Because what I want is when I save a new workbook only module2 can copy/go with new book not module1.

Regards/Amit

Hi Amit,

In a general way all macros will auto get saved in new wb. So, there's might something in ur code which is preventing this!!
 
Ohh Deepak, I might not explained well...anyways its the opposite what you are thinking. In new book all macros autosaved but I don't want it, I want only selected macros to be saved in newbook not all.

Regards/Amit
 
Hi Amit,

If you want to remove entire module, you can write a procedure as given in the below link

http://www.mrexcel.com/forum/excel-...-remove-module-visual-basic-applications.html

If your requirement is more specific like create, change, or delete VBA modules and code procedures, then visit here

Programming The VBA Editor
http://www.cpearson.com/excel/vbe.aspx

You may have to set an reference to the VBA Extensibility library. Read the caution given in http://www.cpearson.com/excel/vbe.aspx

Regards,
Surendran
 
Hi Amit,

If you want to remove entire module, you can write a procedure as given in the below link

http://www.mrexcel.com/forum/excel-...-remove-module-visual-basic-applications.html

If your requirement is more specific like create, change, or delete VBA modules and code procedures, then visit here

Programming The VBA Editor
http://www.cpearson.com/excel/vbe.aspx

You may have to set an reference to the VBA Extensibility library. Read the caution given in http://www.cpearson.com/excel/vbe.aspx

Regards,
Surendran

Hi Surendran,

Many thanks for giving me a good resource to learn new things.

Regards/amit
 
Hi Amit,

Sorry!! i misunderstood the req.

This line will remove the module2 from the activeworkbook.

Code:
ActiveWorkbook.VBProject.VBComponents.Remove ActiveWorkbook.VBProject.VBComponents("Module2")
 
Thanks Deepak, but do I need to enable something to run this because it sending an runtime error [Programmatic access to visual basic project is not trusted]
 
Thanks Deepak, but do I need to enable something to run this because it sending an runtime error [Programmatic access to visual basic project is not trusted]

If u have 2007 then follow steps.
  1. Open the 2007 Microsoft Office system application in question. Click the Microsoft Office button, and then clickApplication Options.
  2. Click the Trust Center tab, and then click Trust Center Settings.
  3. Click the Macro Settings tab, click to select the Trust access to the VBA project object model check box, and then clickOK.
  4. Click OK.
 
If u have 2007 then follow steps.
  1. Open the 2007 Microsoft Office system application in question. Click the Microsoft Office button, and then clickApplication Options.
  2. Click the Trust Center tab, and then click Trust Center Settings.
  3. Click the Macro Settings tab, click to select the Trust access to the VBA project object model check box, and then clickOK.
  4. Click OK.
Thanks a lot :)
 
Back
Top