Username

jmerch

New member
Joined
Feb 14, 2012
Messages
32
Reaction score
0
Points
0
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.

Code:
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
 
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

Code:
[LEFT][COLOR=#333333]If Environ(".UserName") = "josh" Then
[/COLOR][/LEFT]
 
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

Code:
[LEFT][COLOR=#333333]If Environ(".UserName") = "josh" Then[/COLOR][/LEFT]

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.
 
Back
Top