Adding a password on a menu button in excel 
Author Message
 Adding a password on a menu button in excel

Dear Friends,

I have created a template in excel for a user to enter data.
On the sheet their is 2 buttons. One button is submit and the other is
approve. Only certain user may approve the data. Can I create a macro that
when a use click on the approve button he must enter a code before the
button can be pressed?

Thank in advance



Wed, 18 Jun 1902 08:00:00 GMT  
 Adding a password on a menu button in excel
The subject line makes reference to a menu button. The explanation makes
reference to buttons on a sheet. That is what this example assumes. (sheet
buttons) It also assumes an ActiveX command button from the control tool box
rather than a command button from the Forms tool bar. This code goes in the
click event procedure for the command button.

You will need to (1) change "CommandButton1" to your command button name.
(2) Replace the word "PASSWORD" with your password. (3) Replace
"run_your_code" with name of the macro you run when data is approved. (4)
Put this code in the code window for the sheet that has the command button.

'This click event  prompts the user for a password. Input is not case
sensitive. If the password is valid, the
'???? macro runs. If the password is not valid, a message box is sent. After
OK is clicked, the user is 'prompted for the password again. To terminate
the command, click the Cancel button on the Enter Password 'dialog box.

Private Sub CommandButton1_Click()
    Beep
    Do
        Prompt = Application.InputBox("Enter Password")
        If (Prompt = False) Then
            Exit Sub
        ElseIf (UCase(Prompt) <> "PASSWORD") Then
            MsgBox "Invalid Password!", vbCritical
        Else
            Exit Do
        End If
    Loop
    Call run_your_code
End Sub

HTH
Nelson
Kansas City, MO USA


Quote:
> Dear Friends,

> I have created a template in excel for a user to enter data.
> On the sheet their is 2 buttons. One button is submit and the other is
> approve. Only certain user may approve the data. Can I create a macro that
> when a use click on the approve button he must enter a code before the
> button can be pressed?

> Thank in advance



Wed, 18 Jun 1902 08:00:00 GMT  
 Adding a password on a menu button in excel
Hi Waldemar,

There are two was you could approch it.  One would be to create a form with
a text box and Ok button which is called when the person clicks the approve
button.  When they enter a number and click ok you can use either an IF or
Select Case statement to check the value entered.  If the number isn't valid
you can have it put up a message box saying that the password is incorect.

The second way is to use a Input Box.  Here is an article that descibes how
to use an imput box and it has a couple of code eaxamples that may help you
out.

http://support.microsoft.com/support/kb/articles/Q213/6/14.ASP?LN=EN-...
n&FR=0

Hope this helps,

Tom


Quote:
> Dear Friends,

> I have created a template in excel for a user to enter data.
> On the sheet their is 2 buttons. One button is submit and the other is
> approve. Only certain user may approve the data. Can I create a macro that
> when a use click on the approve button he must enter a code before the
> button can be pressed?

> Thank in advance



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Adding a password on a menu button in excel

2. Adding a menu item under the Help menu in Excel

3. Adding a Custom Menu to the Excel Menu Bar

4. Adding a menu item to the main Excel menu bar...glitch in the macro

5. Adding a menu item to the main Excel menu bar...glitch in the macro

6. Adding menu item for Excel Add-In

7. Password change button in menu's

8. add menu-button in Each inspector

9. How to add a menu item or a toolbar button

10. Add button in menu bar with my own picture file


 
Powered by phpBB® Forum Software © phpBB Group