+ Reply to Thread
Results 1 to 3 of 3

Password Protecting Macros

  1. #1
    JAL
    Guest

    Password Protecting Macros

    In Excel 2003. how can I restrict different users within the same file from
    running the same macro? Is there a way to password protect a macro so that
    only the designated user with the correct password can run the macro
    (currently I'm using buttons to initiate the macros)?

  2. #2
    Jim Thomlinson
    Guest

    RE: Password Protecting Macros

    Add in a validation procedure that verifies whether the user is allowed to
    run the specific macro. Create a sheet which will be set very hidden so that
    the user can not see it (without getting inot the code) and designate the
    users who should be allowed to run the macro The list will be their NT user
    names. Your functin will check the NT username against the list. To get the
    username use Environ("User Name)... so the function will look something like
    this... (untested)

    public function AuthorizedUser () as boolean
    dim rngFound as range
    dim rngToSearch As range
    dim wks as worksheet

    set wks = sheets("My Users")
    set rngtosearch = wks.range("A:A")
    set rngfound = rngtosearch.find(Environ("User Name"))

    if rngfound is nothing then
    AuthorizedUser = false
    else
    AuthorizedUser = true
    end if
    end function

    --
    HTH...

    Jim Thomlinson


    "JAL" wrote:

    > In Excel 2003. how can I restrict different users within the same file from
    > running the same macro? Is there a way to password protect a macro so that
    > only the designated user with the correct password can run the macro
    > (currently I'm using buttons to initiate the macros)?


  3. #3
    Neil
    Guest

    RE: Password Protecting Macros

    There are two schoolso f thought on getting the user name, some like the
    'Environ' method, some prefer to to use an API call, as it can be a little
    more secure. There is an example of using the API method at
    http://www.nwarwick.co.uk/Finding_User_Name.htm

    See which you prefer.

    HTH

    Neil
    www.nwarwick.co.uk

    "JAL" wrote:

    > In Excel 2003. how can I restrict different users within the same file from
    > running the same macro? Is there a way to password protect a macro so that
    > only the designated user with the correct password can run the macro
    > (currently I'm using buttons to initiate the macros)?


+ 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