using system variables

philR

Active Member
Joined
Feb 25, 2002
Messages
257
When someone logs onto the network where I work, a system variable called FNAM holds their name. I can get at this in DOS, but is there any way I can get to it in Excel?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
On 2002-05-07 07:26, philR wrote:
When someone logs onto the network where I work, a system variable called FNAM holds their name. I can get at this in DOS, but is there any way I can get to it in Excel?

Do you mean their NT Username?

if yes, copy this into a module:

Option Explicit
' This is used by GetUserName() to find the current user's
' name from the API
Declare Function Get_User_Name Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long


Function GetUserName() As String
Dim lpBuff As String * 25

Get_User_Name lpBuff, 25
GetUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Function

hope this helps.
 
Upvote 0
Wow! That is a very cool piece of code! It does almost what I want, but it is returning "smithj" (which if you type "SET" in DOS is the system variable UNAM) wheras what I want is "John Smith", which is the system variable FNAM. This code must be very close to what I need, but I don't know how to modify it. Incidentally, we are networked on Windows 95, soon to be upgraded to 2000.
Thanks for your help so far,

Phil
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top