+ Reply to Thread
Results 1 to 5 of 5

Protect VBE Project using code

  1. #1
    Forum Contributor
    Join Date
    09-30-2008
    Location
    Eau Claire, WI
    Posts
    184

    Protect VBE Project using code

    Is there a way to protect a VBE project using a macro instead of going to the properties and manually typing in a password? I'm using a macro that emails just one worksheet in my workbook (creates a new temp file, emails, and deletes it) but when the new file gets to the recipient the VBE project is unlocked. I found a way to protect the worksheet before saving the temp file, so the worksheet is protected as it should be, but the project explorer window is completely open. Then anybody can see the passwords I'm using to protect the sheet in the first place. So I need to somehow re-protect the project before it saves and emails. I heard something about sendkeys but I have no clue what that is! Thanks for the help!

    P.S. I'm using Ron's code for doing all this (first method for outlook only, emailing a single worksheet from a workbook.) Thanks!

    HTML Code: 
    Last edited by jman0707; 04-03-2009 at 02:21 PM.

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

    Re: Protect VBE Project using code

    If you are only emailing one sheet then unless the code is in that sheet's code module then your new workbook created by exporting that sheet will not contain any code.
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    09-30-2008
    Location
    Eau Claire, WI
    Posts
    184

    Re: Protect VBE Project using code

    Yeah, it's actually that code that I'm trying to protect. The button runs a macro that unprotects the sheet, copies it, reprotects the sheet and emails it. Within that code is the password to unprotect the sheet since it has to be set in the code. Once the recipient gets the new worksheet he can just open the code and see the password to unlock the worksheet. There's no way to protect the worksheet without having the password in there, but it's pretty much useless to protect the sheet since the recipient can see the code that the password is in. So I need to find a way to protect the code in the new copied worksheet, and the only way to do that is within the macro. Any ideas???

  4. #4
    Forum Contributor
    Join Date
    09-30-2008
    Location
    Eau Claire, WI
    Posts
    184

    Re: Protect VBE Project using code

    I found this, but I heard it's unreliable, and may get a little sticky. Is there another way to do it without using all this? It might get a little difficult trying to integrate this into the email code, and I'm not sure if it would even work.

    Please Login or Register  to view this content.
    Last edited by jman0707; 03-31-2009 at 02:21 PM.

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

    Re: Protect VBE Project using code

    Remove the code from the sheet and place it in a Standard Module, then call that from the button.

+ 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