PDA

View Full Version : Username



jmerch
2012-03-07, 04:53 PM
I have a button in my workbook. It looks at the Application.Username and if it equals a certain value, it puts some print in a cell, if not, an error pops up. This works fine on the original workbook I'm using, but once I save this as something else, it then stops at the username and executes the error. Why? I'm guessing it has something to do with the Username.


Private Sub CommandButton3_Click()
Range("B50").Select
ActiveSheet.Unprotect
If Application.UserName = "josh" Then
ActiveCell.Value = "Bill Kilmer"
ActiveSheet.Protect
ElseIf Application.UserName <> "josh" Then
Answer = MsgBox("You are not Bill!", vbOKOnly)
End If
ActiveSheet.Protect
If Sheets("Chris Burkert").Range("B50") = "Bill Kilmer" Then
Application.Run "'SendEmailJosh'"
End If
End Sub

Bob Phillips
2012-03-08, 09:47 AM
I have no idea why that should happen, but using Application.Username is unreliable, the user can change it. Far better to use their login id




If Environ(".UserName") = "josh" Then

jmerch
2012-03-08, 02:13 PM
I have no idea why that should happen, but using Application.Username is unreliable, the user can change it. Far better to use their login id




If Environ(".UserName") = "josh" Then


I had it set to that before and then changed it :)

I'm not worried about my users changing their username, but I see your point.