+ Reply to Thread
Results 1 to 11 of 11

Delete All Macros In Workbook

  1. #1
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Delete All Macros In Workbook

    So, I found this code on this site that says it can remove all macros on an active workbook.

    Please Login or Register  to view this content.

    Problem is, after I paste that into a module on my Personal Macro Workbook, whenever I go to run it, it has disappeared. It is still in my Visual Basic Editor when I open that back up again, but I am unable to get to it to run because it does not show up in my macros...even after clicking the option for "Macros in: All Open Workbooks"

    Anyone know why?
    Last edited by amyxkatexx; 03-09-2010 at 04:18 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Delete All Macros In Workbook

    It takes an argument, amy.

    You could write a short routine to invoke it:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Delete All Macros In Workbook

    You are amazing! Thank you so much!!

  4. #4
    Registered User
    Join Date
    04-02-2013
    Location
    california, usa
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Delete All Macros In Workbook

    I have tried to run this macro and get the message "the VBProject in Filename is protected or has not components." However, the VBProject is not protected and does have components. What am I doing wrong?

  5. #5
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Delete All Macros In Workbook

    Hi ekr,

    This is a macro that deletes all modules in a workbook, including the DeleteAllModules Module. (I'm not the author of the code below)

    Please Login or Register  to view this content.

    You'll need to go to the vb editor, Tools, References, and enable the "Microsoft Visual Basic for Applications Extensibility"

    Hope it helps

  6. #6
    Registered User
    Join Date
    04-02-2013
    Location
    california, usa
    MS-Off Ver
    Excel 2010
    Posts
    33

    Arrow Re: Delete All Macros In Workbook

    I get the following error message "Programmatic access to Visual Basic Project is not trusted."
    even with MS Visual Basic for Applications Extensibility enabled.

  7. #7
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Delete All Macros In Workbook

    Go to: File, Options, Trust Center, Trust Center Settings...Macro Settings and tick trust access to the vba project model and also tick enable all macros (take note of the warning). Does it solve the problem?

  8. #8
    Registered User
    Join Date
    04-02-2013
    Location
    california, usa
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Delete All Macros In Workbook

    Yes it worked like a charm - I have 12 modules, and it deleted all but one. All modules have similar name (PT1, PT2, etc) and it deleted all but PT8).

  9. #9
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Delete All Macros In Workbook

    Hmmm....don't really know about that one but try it in other workbooks and see if it deletes all modules. Testing it here, it deletes all modules in my active workbook.

  10. #10
    Registered User
    Join Date
    04-02-2013
    Location
    california, usa
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Delete All Macros In Workbook

    Hi - all is working now.I just increased the number associated with the module in the code to exceed the amount of modules I have by 1 and now all is working

  11. #11
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Delete All Macros In Workbook

    Good to know!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1