Userid / machine name / identity / properties

Location: http://www.mvps.org/dmcritchie/excel/userid.htm      
Home page: http://www.mvps.org/dmcritchie/excel/excel.htm
[View without Frames]
UserName Property Example  (from HELP)
   This example displays the name of the current user.
   MsgBox "Current user is " & Application.UserName
Which displays the name as it exists in Tools, Options, General, User Name:
Bernard Liengme 1999-03-31 wrote: This will return the machine name in an NT environment.
 Declare Function GetComputerName& Lib "kernel32" Alias
 "GetComputerNameA" (ByVal lbbuffer As String, nsize As Long)

 Function returnname()
   Dim z As String * 64
   Call GetComputerName(z, 64)
   returnname = z
 End Function

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

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If lngX <> 0 Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = ""
    End If
End Function

Sub PCInformation()
 Dim msg  'David McRitchie, 2002-07-11, misc
 msg = "UserName" & vbTab & Environ$("username") & vbNewLine _
  & "UserProfile" & vbTab & Environ("UserProfile") & vbNewLine _
  & "Computer #" & vbTab & Environ$("ComputerName") & vbNewLine _
  & "Logon Server" & vbTab & Environ$("Logonserver") _
  & vbNewLine & "UserDomain " & vbTab & Environ$("UserDomain")
 MsgBox msg, , "Environment Variables"
End Sub

Watch this area there may be more in the future: (garybeene.com formerly vbinformation.com)
For additional discussions on this look in archives at Google Advanced Usenet Search: http://groups.google.com/advanced_group_search
Search all words:  user name userid
newsgroups:    *excel*

Related


You are one of many distinguished visitors who have visited my site here or in a previous location  since this page was created on July 15, 2000. 

Visit [my Excel home page]   [Index page]   [Excel Onsite Search]   [top of this page]

Please send your comments concerning this web page to: David McRitchie send email comments


Copyright © 1997 - 2004,  F. David McRitchie,  All Rights Reserved