+ Reply to Thread
Results 1 to 5 of 5

Delete macros from workbook on save

  1. #1
    Registered User
    Join Date
    03-24-2011
    Location
    Lancashire
    MS-Off Ver
    Excel 2007
    Posts
    54

    Delete macros from workbook on save

    Hi guys, I was just wondering if there is such a macro for deleting all the macros in a workbook on saving it?

    I have a button within my template workbook that when pressed it "saves as" then hides/deletes on the saved workbook but there are still some macros in the workbook that are not needed upon saving. The reason for asking this is that I have to email my workbook to work but I dont want them to open it with the security warning popping up telling them they have to enable macros.

    Peter

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Delete macros from workbook on save

    Hi Peter,

    You're using Excel 2007, so have you considered saving the workbook as an xlsx file? This would remove all VBA code from it.
    Hope that helps,

    Colin

    RAD Excel Blog

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Delete macros from workbook on save

    Hello Pedro1803,

    This macro will destroy all macro code in workbook before it is saved. If you have locked your VBA project, you need to change the password from "ABC123" to what you are using.

    Delete All MAcros Before Saving
    Please Login or Register  to view this content.

    How to Save a Workbook Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on any Worksheet's Name Tab
    3. Left Click on View Code in the pop up menu.
    4. Press ALT+F11 keys to open the Visual Basic Editor.
    5. Press CTRL+R keys to shift the focus to the Project Explorer Window
    6. Press the Down Arrow Key until ThisWorkbook is highlighted in blue.
    7. Press the Enter key to move the cursor to the Code Window
    8. Paste the macro code using CTRL+V
    9. Save the macro in your Workbook using CTRL+S
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    02-13-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Delete macros from workbook on save

    sorry for bumping the old thread, but, I just want to ask, if I assign this code to some button, will it work when I click it?
    thanks..

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Delete macros from workbook on save

    Yes it should work.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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