Closed Thread
Results 1 to 7 of 7

vb code to delete macro before save file

  1. #1
    Registered User
    Join Date
    10-24-2007
    Posts
    37

    vb code to delete macro before save file

    Is it possible to delete an existing macro in an excel file and save it as a new file without that macro. tried and failed on Web in finding the solution.
    need vb code to do that.thanks in advance.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See if link helps

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

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    10-24-2007
    Posts
    37
    Thanks, VBA Noob.
    I tried that before this posting, but it gave compile error"user-defined type not defined".
    sub delmacro()
    Dim VBProj As VBIDE.VBProject
    Dim VBComp As VBIDE.VBComponent

    Set VBProj = ActiveWorkbook.VBProject
    Set VBComp = VBProj.VBComponents("mymacro")
    VBProj.VBComponents.Remove VBComp
    end sub

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Please read forum rules below and then wrap your code as per rule 5

    VBA Noob

  5. #5
    Registered User
    Join Date
    10-24-2007
    Posts
    37
    sorry, i didn't get it. so there is no way to save a new excel file(from an existing file) without macros or by removing macros ?

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Quote Originally Posted by mixel
    sorry, i didn't get it.
    If you don't understand how to wrap code see link

    Wrap Code

    as per rule 5

    5). Never post any code without using the Code Tags. Posting of any code without code tags makes your code hard to read and often impossible to be copied for testing. For more information about code tags
    VBA Noob

  7. #7
    Registered User
    Join Date
    10-24-2007
    Posts
    37
    no problem. wrapping didn't help either.

Closed 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