Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default function wil not update sheet

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default function wil not update sheet

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update a autofilter sheet from another sheet Don Excel Discussion (Misc queries) 1 June 18th 08 12:57 PM
Update from different sheet shakey1181 Excel Discussion (Misc queries) 0 May 15th 07 02:38 PM
insert query into excell sheet to update excell sheet and pivot table vbsolo Excel Discussion (Misc queries) 0 August 24th 05 12:41 PM
update sheet on the web marwan Excel Discussion (Misc queries) 0 March 16th 05 07:53 PM
Sheet Update Help tiptop[_5_] Excel Programming 2 July 26th 04 04:00 AM


All times are GMT +1. The time now is 03:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"