Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Put these in a general module. They work together to get the logon name.
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 "dragontale <" wrote: From your reply: 'put the following procedures in a standard module: ----- Public Function XLUserName() As String XLUserName = Application.UserName End Function Public Function WinUserName() As String WinUserName = Environ("UserName") End Function --- I have tried this and find out that the second function is not used. And the username is not the login name of the window. And when I replace the XLUserName = Application.UserName to XLUserName = WinUserName , I got a compile error: "Can't find project or Library" Anything I did wrong here, Please help. Thanks in advance --- Message posted from http://www.ExcelForum.com/ -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
activate/deactivate macro depending on who's the user | Excel Discussion (Misc queries) | |||
Defining user access (via user id) using macros | Excel Discussion (Misc queries) | |||
Excel crashes depending on user?? | Excel Discussion (Misc queries) | |||
Lock and unlock cells conditionally depending on input in another | Excel Worksheet Functions | |||
Multi-User Access to a worksheet | Excel Programming |