Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Password Protecting a command button
I need to know how to set a command button, which clears many pages of
information to be there, but only accessable to the right people. E. I. those with the password. I don't want anyone to clear by accident. Is there a way to protect only that button and leave the rest of the sheet accessable to everyone else in the shared workbook? Can this be done with a setting or with a string of programming. Please help. A |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Password Protecting a command button
hi A
you could try using a inputbox something like below should give you an idea of what to do Option Explicit Dim mypassword As String Private Sub CommandButton1_Click() mypassword = Application.InputBox("Please Enter Password", "Restricted") If mypassword = "test" Then 'set your password here MsgBox ("run your code here") ' add your own code to delete sheets here Else mypassword = Application.InputBox("Incorrect Password try again", "Restricted") 'try again End If End Sub hope this is of some use for you S |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Password Protecting a command button
My first thought would be to insert a message box in the button's code which
asks for a password. If the password is not given, or "Cancel" is clicked, the macro will abort. You could either include the password in the code or have the code refer to a cell on a hidden (and protected) sheet. I woiuld even go so far as to have the font of that cell white so the password is not visible to anyone who unhides the sheet. -- Best wishes, Jim "newguyA14" wrote: I need to know how to set a command button, which clears many pages of information to be there, but only accessable to the right people. E. I. those with the password. I don't want anyone to clear by accident. Is there a way to protect only that button and leave the rest of the sheet accessable to everyone else in the shared workbook? Can this be done with a setting or with a string of programming. Please help. A |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Password Protecting a command button
Note that security in Excel/VBA is very weak, so that anyone determined to
circumvent your password protection will be able to do it. That said, try something like Dim PW As String PW = InputBox("Enter Password") If StrComp(PW,"CorrectPassword",vbBinaryCompare) < 0 Then MsgBox "Bad Password" Exit Sub End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting LLC www.cpearson.com (email on the web site) "newguyA14" wrote in message ... I need to know how to set a command button, which clears many pages of information to be there, but only accessable to the right people. E. I. those with the password. I don't want anyone to clear by accident. Is there a way to protect only that button and leave the rest of the sheet accessable to everyone else in the shared workbook? Can this be done with a setting or with a string of programming. Please help. A |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Password Protecting a command button
Make the Command Button visible only after the entry in a Text Box of the
correct password. If Active Directory is in use in your network environment, you may just want to enable particular users, without the bother of a password. The following routine sets the Application.Username field to the user's Active Directory entry. Call this from the Workbook_Open event, or in the Initialize event of the user form ------------------------------- Sub GetNameFromAD() Dim sDisplayName As String On Error GoTo NoConnection 'If laptop user not logged onto network Set oADSystemInfo = Nothing ' Get full username from AD Set oADSystemInfo = CreateObject("ADSystemInfo") ' get AD user object Set oADsUser = GetObject("LDAP://" & oADSystemInfo.UserName) ' get full name of the current user sDisplayName = oADsUser.DisplayName Application.UserName = sDisplayName Set oADSystemInfo = Nothing NoConnection: End Sub ---------------------------- Now reference the Application.UserName to check who the user is. -- HTH Roger Shaftesbury (UK) "newguyA14" wrote in message ... I need to know how to set a command button, which clears many pages of information to be there, but only accessable to the right people. E. I. those with the password. I don't want anyone to clear by accident. Is there a way to protect only that button and leave the rest of the sheet accessable to everyone else in the shared workbook? Can this be done with a setting or with a string of programming. Please help. A |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Password Protecting a command button
Ok, I am somewhat of a novice to this. I have built this program, but it has
taken awhile and alot of what I have done I have asked for help on. Can someone take one of these suggestions and kind of slow it down for me, like a play by play. I'm not sure whether this would go under the code of the page, or do I need this under a specific object. the page this is on is called "Note Tracker" and the command box is "Clear all Messages". Any help is appreciated. A " wrote: hi A you could try using a inputbox something like below should give you an idea of what to do Option Explicit Dim mypassword As String Private Sub CommandButton1_Click() mypassword = Application.InputBox("Please Enter Password", "Restricted") If mypassword = "test" Then 'set your password here MsgBox ("run your code here") ' add your own code to delete sheets here Else mypassword = Application.InputBox("Incorrect Password try again", "Restricted") 'try again End If End Sub hope this is of some use for you S |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Password Protecting a command button. | Excel Programming | |||
VB's Command Button vs Form's Command Button | Excel Programming | |||
how can I assign a password to a command button | Excel Programming | |||
Password Protecting | Excel Discussion (Misc queries) | |||
Command Button Password | Excel Programming |