View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Username The Sequel

What he means is that the Username under Options is just a string which can
be changed and cannot be relied upon. Better to rely upon the username that
the user logs into the machine with, and use this value. This simple UDF
returns the logged on user name

Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long

Public Function UserName() As String
Dim sName As String * 256
Dim cChars As Long
cChars = 256
If GetUserName(sName, cChars) Then
UserName = Left$(sName, cChars - 1)
End If
End Function

So where you use Application.Username, add a call to this function instead.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"teabag" wrote in message
...
Onedaywhen's answer to Lawlera's query about restricting changes to the

Username box under Options was:

"That's why you should always check the username (or full name) they
used to log on."

I am trying to prevent impersonation in a shared workbook with tracked

changes. What does the above reply mean (How to check? How can it be
recorded?) and how could I use it to stop abuse of the Username box?

Reply in very straightforward layman's terms would be very much

appreciated. Thanks.