+ Reply to Thread
Results 1 to 4 of 4

Protect a sheet with a password, but secure the password

  1. #1
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Protect a sheet with a password, but secure the password

    I have some code that requires that I un-protect and re-protect some worksheets with the use of a button on the page. I use command button VBA code to perform this. What I'd like to do is to provide a password to the command to protect the page but to prevent someone from being able to review the code and capture the password.

    How is this performed?

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Protect a sheet with a password, but secure the password

    If you protect the worksheet with VBA, one of the arguments of Protect is UserInterfaceOnly.
    When set to TRUE, VBA code can access all aspects of the sheet without unprotecting it, while users will be restricted.

    Example:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Re: Protect a sheet with a password, but secure the password

    Yes, I can work with that. I'm using this in a template, an .xltm file, but I'm struggling to determine how to protect someone from using alt-F11 and seeing the password? I tried to use the feature to secure the VBAProject with a password, but this does not appear to get passed onto any files created by the template.

    I also noticed that when I save the file created by the template it asks for the password for that page. I set the supplied code in a page of the template file and the prompt occurs when I try and save a file created by the template. Am I using the command incorrectly?
    Last edited by JimDandy; 06-16-2013 at 01:44 AM.

  4. #4
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Re: Protect a sheet with a password, but secure the password

    Update..I use this code in BeforeSave and Open forms and that seems to be where I'm getting the password prompts. I realised that I needed to reference the specific page, ActiveSheet is incorrect in this instance.

    I still have the issue that by protecting the VBAProject with a password in my template file, this password is not passed down to the files created by the template. Is there some way to perform that?

    Final update...It appears that I must have been doing something wrong as it seems that the password is passed from template to the resultant document.

    Thank you Ron for your help with this...
    Last edited by JimDandy; 06-16-2013 at 02:17 AM. Reason: I was finally able to pull my head out...

+ 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