+ Reply to Thread
Results 1 to 3 of 3

Password Setting on a macro button

  1. #1
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Password Setting on a macro button

    Hello,

    I have this macro and I want to add a password so that nobody is able to click the button for the macro.

    If some user try to click the button, it will prompt a passcode with "cancel" option or return to worksheet.

    Thanks.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Password Setting on a macro button

    You could use an inputbox or a UserForm, but it's not really secure and there's likely nothing to stop someone saving a copy manually or copying the file and renaming it.
    "Documents" is usually associated with a User, but in any case the file is saved locally. What's the idea behind trying to prevent it?

  3. #3
    Forum Contributor
    Join Date
    10-02-2012
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    252

    Re: Password Setting on a macro button

    As ByteMarks said, the password can easily be bypassed. In order to prevent unauthorized access to files at my place of work, we implement the use of Environ("USERNAME") function to check if the user is found in the list of authorized users.

    This could be used in a similar fashion for this case;

    In the ThisWorkbook pane in the VBA editor, try this code:

    Please Login or Register  to view this content.
    If you don't know your username you can run Environ("USERNAME") on yourself in a separate macro.

    You can then set the VBA editor to be password protected on that file by right-clicking in the Project pane, selecting "VBAProject Properties", selecting "Protection" and enable the password protection and remove access to view the code.

    If anyone other than yourself tries to run your original macro, they won't be able to save.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Password Protect Button Not the Macro
    By Billy Spivy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-15-2018, 11:30 AM
  2. Password protect macro button
    By gmccormick in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-12-2012, 06:10 AM
  3. Password protect macro button??
    By Denzil in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-03-2012, 04:24 AM
  4. Password protection for a macro button
    By ramakavin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-08-2008, 05:22 PM
  5. Setting password to pdf through VB Macro
    By Mrunalini in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-23-2008, 05:10 AM
  6. Assign a password to a macro button?
    By caliskier in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2007, 01:18 PM
  7. Replies: 4
    Last Post: 08-18-2005, 11:05 AM

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