+ Reply to Thread
Results 1 to 9 of 9

Password Protect Running of Macro

  1. #1
    John
    Guest

    Password Protect Running of Macro

    Is it possible to Password protect the running of a Macro

    I have a Macro that I only want certain people to be able to Run, I have
    created the Macro but before it runs / executes I would like a dialog box to
    pop up with a required password input, If the password is incorrect the
    action is just cancelled

    Thanks



  2. #2
    John
    Guest

    Re: Password Protect Running of Macro

    Did a search of Groups and spotted this neat code to do what I require

    Sub PasswordForAMacro()
    Dim Message As String, Title As String
    Dim MyValue As String
    Message = "Please enter your password to access this"
    Title = "Run Macro"
    MyValue = InputBox(Message, Title, Default)
    If MyValue <> "1234" Then
    MsgBox "Invalid password - you cannot access this"
    Exit Sub
    Else
    'type the actions / code you require to run'

    ActiveSheet.Range("A1").Select
    End If
    End Sub






    "John" <[email protected]> wrote in message
    news:[email protected]...
    > Is it possible to Password protect the running of a Macro
    >
    > I have a Macro that I only want certain people to be able to Run, I have
    > created the Macro but before it runs / executes I would like a dialog box
    > to pop up with a required password input, If the password is incorrect the
    > action is just cancelled
    >
    > Thanks
    >
    >




  3. #3
    John
    Guest

    Re: Password Protect Running of Macro

    Is there an input mask that will enter the Password as **** instead of 1234?

    I will be accessing this log on lineso a user in the remote location might
    see the password I type in


    "John" <[email protected]> wrote in message
    news:%[email protected]...
    > Did a search of Groups and spotted this neat code to do what I require
    >
    > Sub PasswordForAMacro()
    > Dim Message As String, Title As String
    > Dim MyValue As String
    > Message = "Please enter your password to access this"
    > Title = "Run Macro"
    > MyValue = InputBox(Message, Title, Default)
    > If MyValue <> "1234" Then
    > MsgBox "Invalid password - you cannot access this"
    > Exit Sub
    > Else
    > 'type the actions / code you require to run'
    >
    > ActiveSheet.Range("A1").Select
    > End If
    > End Sub
    >
    >
    >
    >
    >
    >
    > "John" <[email protected]> wrote in message
    > news:[email protected]...
    >> Is it possible to Password protect the running of a Macro
    >>
    >> I have a Macro that I only want certain people to be able to Run, I have
    >> created the Macro but before it runs / executes I would like a dialog box
    >> to pop up with a required password input, If the password is incorrect
    >> the action is just cancelled
    >>
    >> Thanks
    >>
    >>

    >
    >




  4. #4
    r.bell321
    Guest

    Re: Password Protect Running of Macro


    I don't know a way, but I know a workaround

    Say the password was bob12, at the start of your subroutine you could
    have the line

    If InputBox("Enter password") = "bob12" Then
    etc....
    end if

    THis would prompt for a password. You would then have to protect your
    VBAProject to stop people seeing this.


    --
    r.bell321Posted from - http://www.officehelp.in


  5. #5
    Chip Pearson
    Guest

    Re: Password Protect Running of Macro

    You can't do that with an inputbox. You'd need a userform with a
    textbox whose PasswordChar property set to "*".

    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "John" <[email protected]> wrote in message
    news:[email protected]...
    > Is there an input mask that will enter the Password as ****
    > instead of 1234?
    >
    > I will be accessing this log on lineso a user in the remote
    > location might see the password I type in
    >
    >
    > "John" <[email protected]> wrote in message
    > news:%[email protected]...
    >> Did a search of Groups and spotted this neat code to do what I
    >> require
    >>
    >> Sub PasswordForAMacro()
    >> Dim Message As String, Title As String
    >> Dim MyValue As String
    >> Message = "Please enter your password to access this"
    >> Title = "Run Macro"
    >> MyValue = InputBox(Message, Title, Default)
    >> If MyValue <> "1234" Then
    >> MsgBox "Invalid password - you cannot access this"
    >> Exit Sub
    >> Else
    >> 'type the actions / code you require to run'
    >>
    >> ActiveSheet.Range("A1").Select
    >> End If
    >> End Sub
    >>
    >>
    >>
    >>
    >>
    >>
    >> "John" <[email protected]> wrote in message
    >> news:[email protected]...
    >>> Is it possible to Password protect the running of a Macro
    >>>
    >>> I have a Macro that I only want certain people to be able to
    >>> Run, I have created the Macro but before it runs / executes I
    >>> would like a dialog box to pop up with a required password
    >>> input, If the password is incorrect the action is just
    >>> cancelled
    >>>
    >>> Thanks
    >>>
    >>>

    >>
    >>

    >
    >




  6. #6
    Gazza
    Guest

    Re: Password Protect Running of Macro

    How would one set up the routine to provide a usertform rather than an input
    box then?

    Gazza

    "Chip Pearson" <[email protected]> wrote in message
    news:[email protected]...
    > You can't do that with an inputbox. You'd need a userform with a textbox
    > whose PasswordChar property set to "*".
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    > "John" <[email protected]> wrote in message
    > news:[email protected]...
    >> Is there an input mask that will enter the Password as **** instead of
    >> 1234?
    >>
    >> I will be accessing this log on lineso a user in the remote location
    >> might see the password I type in
    >>
    >>
    >> "John" <[email protected]> wrote in message
    >> news:%[email protected]...
    >>> Did a search of Groups and spotted this neat code to do what I require
    >>>
    >>> Sub PasswordForAMacro()
    >>> Dim Message As String, Title As String
    >>> Dim MyValue As String
    >>> Message = "Please enter your password to access this"
    >>> Title = "Run Macro"
    >>> MyValue = InputBox(Message, Title, Default)
    >>> If MyValue <> "1234" Then
    >>> MsgBox "Invalid password - you cannot access this"
    >>> Exit Sub
    >>> Else
    >>> 'type the actions / code you require to run'
    >>>
    >>> ActiveSheet.Range("A1").Select
    >>> End If
    >>> End Sub
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>> "John" <[email protected]> wrote in message
    >>> news:[email protected]...
    >>>> Is it possible to Password protect the running of a Macro
    >>>>
    >>>> I have a Macro that I only want certain people to be able to Run, I
    >>>> have created the Macro but before it runs / executes I would like a
    >>>> dialog box to pop up with a required password input, If the password is
    >>>> incorrect the action is just cancelled
    >>>>
    >>>> Thanks
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >




  7. #7
    r.bell321
    Guest

    Re: Password Protect Running of Macro


    The original subroutine would have to read:
    Sub PasswordForAMacro()
    Userform1.Show
    End Sub

    You would need a userform (called Userform1) with a text box (called
    Textbox1 with PasswordChar property set to "*") and a button (called
    Button1) to submit the userform. Then put the following code in the
    userform

    Sub Button1_Click()
    If Textbox1.text <> "1234" Then
    MsgBox "Invalid password - you cannot access this"
    Userform1.Hide
    Exit Sub
    Else
    'type the actions / code you require to run'
    Userform1.Hide
    End If


    --
    r.bell321Posted from - http://www.officehelp.in


  8. #8
    John
    Guest

    Re: Password Protect Running of Macro

    Thanks R.Bell, thats neat


    "r.bell321" <[email protected]> wrote in message
    news:[email protected]...
    >
    > The original subroutine would have to read:
    > Sub PasswordForAMacro()
    > Userform1.Show
    > End Sub
    >
    > You would need a userform (called Userform1) with a text box (called
    > Textbox1 with PasswordChar property set to "*") and a button (called
    > Button1) to submit the userform. Then put the following code in the
    > userform
    >
    > Sub Button1_Click()
    > If Textbox1.text <> "1234" Then
    > MsgBox "Invalid password - you cannot access this"
    > Userform1.Hide
    > Exit Sub
    > Else
    > 'type the actions / code you require to run'
    > Userform1.Hide
    > End If
    >
    >
    > --
    > r.bell321Posted from - http://www.officehelp.in
    >




  9. #9
    Jon
    Guest

    Re: Password Protect Running of Macro

    Of course you had better password protect your code as well.

    Jon
    "John" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks R.Bell, thats neat
    >
    >
    > "r.bell321" <[email protected]> wrote in message
    > news:[email protected]...
    >>
    >> The original subroutine would have to read:
    >> Sub PasswordForAMacro()
    >> Userform1.Show
    >> End Sub
    >>
    >> You would need a userform (called Userform1) with a text box (called
    >> Textbox1 with PasswordChar property set to "*") and a button (called
    >> Button1) to submit the userform. Then put the following code in the
    >> userform
    >>
    >> Sub Button1_Click()
    >> If Textbox1.text <> "1234" Then
    >> MsgBox "Invalid password - you cannot access this"
    >> Userform1.Hide
    >> Exit Sub
    >> Else
    >> 'type the actions / code you require to run'
    >> Userform1.Hide
    >> End If
    >>
    >>
    >> --
    >> r.bell321Posted from - http://www.officehelp.in
    >>

    >
    >




+ 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