Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a worksheet with a username function in it. The cell with the
function call =fOSUserName() will not update if another user is using the worksheet. If I manualy edit and enter the cell again it works great. If I calculate the sheet at start with the auto_open macro it makes no difference, it wil keep the last saved name. What could be wrong?? In the future I want to use this function in a shared file is....Also a problem?? The Function looks and macro looks like: (by the way this comes from this great group....) 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 GetUserNameTest() MsgBox fOSUserName End Sub Sub auto_open() Worksheets("blad1").Calculate End Sub Jan..... |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would have thought that the function would evaluate correctly, but...
This is untested (I only have one logon id): How about: sub auto_open with worksheets("blad1") .cells.Replace What:="=", Replacement:="=", _ LookAt:=xlPart, SearchOrder:=xlByRows, _ MatchCase:=False .calculate '??? end with end sub It's just doing an Edit|replace what: = (equal sign) with: = (equal sign) replace all. This function does get the logon name--so if both users were using the same pc (and the first didn't logoff, then it won't help.) But there is an application.username (it picks up the name from Tools|Options|general tab|user name box) Jan Grinwis wrote: I have a worksheet with a username function in it. The cell with the function call =fOSUserName() will not update if another user is using the worksheet. If I manualy edit and enter the cell again it works great. If I calculate the sheet at start with the auto_open macro it makes no difference, it wil keep the last saved name. What could be wrong?? In the future I want to use this function in a shared file is....Also a problem?? The Function looks and macro looks like: (by the way this comes from this great group....) 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 GetUserNameTest() MsgBox fOSUserName End Sub Sub auto_open() Worksheets("blad1").Calculate End Sub Jan..... -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Update a autofilter sheet from another sheet | Excel Discussion (Misc queries) | |||
Update from different sheet | Excel Discussion (Misc queries) | |||
insert query into excell sheet to update excell sheet and pivot table | Excel Discussion (Misc queries) | |||
update sheet on the web | Excel Discussion (Misc queries) | |||
Sheet Update Help | Excel Programming |