+ Reply to Thread
Results 1 to 13 of 13

Macro to "self-destruct"

  1. #1
    Registered User
    Join Date
    06-16-2011
    Location
    Zoetermeer, The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    9

    Question Macro to "self-destruct"

    Hello,

    I've got an Excel-sheet with a macro for my work, but because the Excel-file will be send to a lot of offices when I'm done with it, I want to add a rule in the macro that "self-destructs" the macro... Is this possible?

    Best regards,

    Chris
    Last edited by Sharkey79; 06-21-2011 at 07:18 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro to "self-destruct"

    You can save it as a .csv file.

    In E2007 you can save it as an xlsx file.
    Last edited by snb; 06-21-2011 at 05:39 AM.



  3. #3
    Registered User
    Join Date
    06-16-2011
    Location
    Zoetermeer, The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to "self-destruct"

    Hi snb,

    Although you're answer might work and you are appreciated for it, it's not what I want...
    Is there a way to make the macro delete itself?

    Chris

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro to "self-destruct"

    Why would you want to avoid the simplest method ?

  5. #5
    Registered User
    Join Date
    06-16-2011
    Location
    Zoetermeer, The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to "self-destruct"

    Because multiple people have to be able to use it without the knowledge of Excel. A key combination everyone can remember without to many questions. Saving it in a different file-extension is another story...

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro to "self-destruct"

    There's info here on deleting all the code in a project: http://www.cpearson.com/excel/vbe.aspx

    I'd agree with snb though in that you'd be better off just saving it as a macro free file.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro to "self-destruct"

    You can even build a macro that performs everything. They don't even have to remember any key combination at all.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-16-2011
    Location
    Zoetermeer, The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to "self-destruct"

    Hi Domski,

    Thanks for the tip and the advice... I'll try the method on the site and see what works best for me (and my colleagues).

    Chris

  9. #9
    Registered User
    Join Date
    06-16-2011
    Location
    Zoetermeer, The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to "self-destruct"

    Quote Originally Posted by snb View Post
    You can even build a macro that performs everything. They don't even have to remember any key combination at all.

    Please Login or Register  to view this content.
    I was out for lunch and forgot to press submit reply for Domski's post so I didn't see this reply until I submitted the thanks to Domski.

    But this looks really good too! Can you explain how this macro works?

    Thanks,

    Chris

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro to "self-destruct"

    Please do not quote.

    When the user closes eg. the file "E:\OF\example.xls" it will automatically also be saved as "E:\OF\example.csv".
    This file doesn't contain macro's. When a user opens it in Excel it's automatically a workbook and can be used/written into as a normal Excelfile.

    There are many more methods depending on what you wish (keep the formatting or only the data, whether the workbook contains 1 or more sheets, etc.)

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to "self-destruct"

    Using Chip Pearson's code you would not be able to protect the VBA project
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  12. #12
    Registered User
    Join Date
    06-16-2011
    Location
    Zoetermeer, The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to "self-destruct"

    @snb

    Off topic: What's wrong with "quoting"??
    On topic: Okay, that sounds good! Couldn't get the Chip Pearson to work (gives an error) so that would be the best way to go. And you're macro would also help a lot on another problem I've got! Thanks a million snb!

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro to "self-destruct"

    Off topic: What's wrong with "quoting"??
    Apparently you didn't read the forum rules (nr. 12)

    Please Login or Register  to view this content.

+ 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