Consulting

Results 1 to 11 of 11

Thread: Protecting coding

  1. #1
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    4
    Location

    Protecting coding

    I'm releasing some of workbooks onto some people to test. I have a procedure that deletes the workbook, but I'd like to run this as soon as the VBE is opened. What coding do I use and where should I place it?

    Many thanks,
    Dom

  2. #2
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Hi, welcome to VBAX!! Put the code in the Workbook Open event. To find that, open the VBE and click on the top left and change to Workbook. Then on the right change to open. The code goes in there.

  3. #3
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    4
    Location
    Thanks for the quick reply.

    Would this be everytime the workbook opened or everytime the VBE opened? I'd like it to only be when the visual basic editor window was opened. Cheers,

    Dom

    Cheers

  4. #4
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Oh, that puts a different twist on it. Not sure if it can be done or not. If it can you can bet someone here can help you. I dont know for sure.

  5. #5
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Point of clarification. You want to delete the whole workbook or just the code? I would assume the code.

  6. #6
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    See if this KB entry helps you. I could be modified to do what you wish.

    http://www.vbaexpress.com/kb/getarticle.php?kb_id=511

  7. #7
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    4
    Location
    Either delete all the coding / UF's etc...
    or delete the entire workbook.

    I have a procedure that deletes the workbook, I just need a place to call it.

    Ideally it would be in activation of the VBE, but can't figure out how to get this.

    Thanks again

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why would it be the activation of the VBIDE? In normal workbook processing, it wouldn't be opened at all. In what circumstances would you be activating it?

  9. #9
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    4
    Location
    Well i want them to use the workbook, just not access the coding! So on activation of the vba window it would run a procedure that would shut it down.

    Dom

  10. #10
    I have an excel workbook that I send out every month to our customers. To protect the knowledge behind it, I just lock it for viewing in VBE by going to properties of the project in VBE and then to the Protection tab and lock for viewing and put in a password (a very long password). In addition I put a timer in it so that the tool locks out every 45 days so that it can not be accessed.

  11. #11
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    You're wasting your time trying to provide fool-proof security in VBA, there's just too many ways to get around it.

    However, maybe you'd like to try modifying this to suit, it uses the On-Time method to check if the VBE window's open/unlocked and then deletes all VBA code if a hidden password isn't there, but you'd really need to modify it so it's used in an add-in to maybe have some chance of success...

    Note that you can only ever provide some extra levels of protection, but don't make the mistake of thinking "protection" is "security" - it is not. Excel VBA is not a secure environment
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

Posting Permissions

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