LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Update username

Hello there,

I have a function in a module that retrieves the system's username. Hereit is:

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


Now, this is a copy&paste from another example, I won't pretend that I
understand how this function works, but it does work. When I created this
workbook I added in cells several spreadsheets the formula =fosusername() and
indeed those cells showed my username. The problem I'm having is that now
when someone else opens the file it still shows my username.

I know that adding code for every single cell in every single spreadsheet
where I need the username will work (Range("XX")=fosusername()) but...is
there a way to "update" the value of this function, for example, when the
workbook is opened, so that I will not have to add code in all spreadsheets?

Thanks!

A.
 
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
environ username vs. application username jatman Excel Programming 4 May 28th 09 08:40 AM
username robzrob Excel Worksheet Functions 2 May 4th 08 05:59 PM
Username Alvin Hansen[_2_] Excel Programming 3 September 25th 04 10:36 PM
username libby Excel Programming 8 April 25th 04 03:37 AM
Get NT Username Steven Pugh Excel Programming 7 February 20th 04 09:37 AM


All times are GMT +1. The time now is 09:22 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"