LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Use % as variable for user id?

Thanks. I'm going to use environ. That will work on my OS and that of all of my users.
--
RMC,CPA


"Gary L Brown" wrote in message ...
Yes and No. :O

Environ gives you the user name for the Windows login.
The function I supplied gives the user name for the network login.

They are almost always the same but can be different. That's why the 'yes'
and 'no' answer.

Hope one of the solutions supplied is what you are looking for.
Sincerely,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"R. Choate" wrote:

What I needed was the simple

strUser = Environ("username")

that yields whatever the user is logged on as. I think this is likely the same info returned by the long API call you referenced,
but I'm not sure.

Thanks,
--
RMC,CPA


"Gary L Brown" wrote in message ...
Not sure exactly what you want but the following user-defined-function can be
used to get the Network User Name. Just run the 'ShowNetName' macro...

'/=================================================/
Private Declare Function GetUserName Lib "ADVAPI32.DLL" _
Alias "GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long

'/=================================================/
Sub ShowNetName()
MsgBox GetNetworkUserName
End Sub
'/=================================================/
Private Function GetNetworkUserName() As String
Dim strUserName As String

On Error GoTo Err_GetNetworkUserName

strUserName = String(255, 0)
GetUserName strUserName, Len(strUserName)

GetNetworkUserName = Application.WorksheetFunction. _
Clean(strUserName)

Exit_GetNetworkUserName:
Exit Function

Err_GetNetworkUserName:
GetNetworkUserName = ""
Resume Exit_GetNetworkUserName

End Function
'/=================================================/

HTH,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"R. Choate" wrote:

Can I initialize the % sign as a variable in code to identify and use to indicate the user id of the user who is running the
code
on
their station? For example X = %. or something like that.

Thanks,
--
RMC,CPA









 
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
Transfer variable to user Form jlclyde Excel Discussion (Misc queries) 2 April 23rd 10 08:25 PM
Pass Excel User License to Variable Tom Ogilvy Excel Programming 0 October 11th 05 12:55 PM
User input formula variable Petr Excel Programming 3 December 9th 04 01:59 PM
Excel VBA - Find User Inputted Variable andibevan Excel Programming 3 June 9th 04 03:55 PM
Calling variable from user form Geraldon Excel Programming 2 February 9th 04 03:18 PM


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