Results 1 to 4 of 4

Thread: Passwording a Macro

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    38

    Passwording a Macro

    How do I assign a password to a macro? I.e. before you run the macro you must enter a password.

    Is it difficult to manage/change/update etc?

    Many Thanks

  2. #2
    Junior Member
    Join Date
    Mar 2003
    Location
    Mt. Holly, NJ
    Posts
    31
    This is very easy

    Just create a variable called strPassword. Assign it a value like "mywords" and then have a message box pop up at the beginning of the macro. If the password they enter does not match your strPassword variable, the macro quits. if not, it runs. Of course, if someone opens your macro to view the code, they will be able to see your password.

    Josh

  3. #3
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Better yet, stay away from macros.

  4. #4
    Lively Member TheFIDDLER's Avatar
    Join Date
    May 2002
    Location
    here and there and far away
    Posts
    126
    Lock your project with a VBA password so that they cannot can into your code and glance easily at the macro password.
    (VBA menu, Under tools, VBA Project Properties, Lock Project for Viewing)


    As for the password itself, quite simple.

    Dim x as string
    x = "password"
    display = inputbox("Please enter password")
    if display <> x then exit sub
    ... rest of code

    Note, be creative, using password as a password is lame.

    As to maintenance, just edit the code and change the value you assign to X.

Posting Permissions

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



Click Here to Expand Forum to Full Width