+ Reply to Thread
Results 1 to 3 of 3

VBA to delete all Macros

  1. #1
    Registered User
    Join Date
    01-07-2006
    Posts
    26

    VBA to delete all Macros

    I have found a couple examples of how to do this on the web, but they have been 100% ineffective, or possibly I am not seeing where I need to change the code. Can anyone point me in the right direction?

    The code i have is:

    Please Login or Register  to view this content.
    My goal is to ultimately have the program delete all the vba in the file, and then save the file....almost as a sort of copy protection.

  2. #2
    Registered User
    Join Date
    10-06-2006
    Posts
    16
    theres an easier way to do this.
    rather than delete the macros and save the file.
    just make a new workbook and save the file to the new workbook.
    the new book won't have any macros to delete.


    Private Sub SAVE_AS()

    Application.DisplayAlerts = False

    FILENAME = UCase(path)

    Sheets("sheet2").Select
    Set wb = Workbooks.Add
    ThisWorkbook.Sheets("sheet2").Copy Before:=wb.Sheets(1)
    For i = wb.Sheets.Count To 2 Step -1
    wb.Sheets(i).Delete
    Next i
    wb.Sheets(1).Name = "give it a name"
    wb.SaveAs (FILENAME)
    Application.DisplayAlerts = True
    wb.Close
    Set wb = Nothing

    End Sub
    Last edited by Mike k; 12-13-2006 at 08:16 AM.

  3. #3
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    VBE can be a solution ...to handle VBA code ...

    http://www.cpearson.com/excel/vbe.htm

    HTH
    Carim

+ 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