J
Jumbo Shrimps Jr
The following code allows me to type =fOSUserName()
in a cell and the name of the current logged on user
is displayed.
When someone else opens the spreadsheet, the name of the
last person who opened the spreadsheet appears (not the
current user as I thought) in the cell until the function
is copied to a new cell, when the current logged on user's
name appears in the new cell.
Is there any F9-type way to refresh cells so that functions
are refreshed when the spreadsheet is opened?
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 = vbNullString
End If
End Function
in a cell and the name of the current logged on user
is displayed.
When someone else opens the spreadsheet, the name of the
last person who opened the spreadsheet appears (not the
current user as I thought) in the cell until the function
is copied to a new cell, when the current logged on user's
name appears in the new cell.
Is there any F9-type way to refresh cells so that functions
are refreshed when the spreadsheet is opened?
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 = vbNullString
End If
End Function