Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Getting the systems username

Does anyone know how threw VBA to get the systems username
or login name. I can get the Application.UserName, but it
might not be the same for someone loging in at a diffrent
location?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Getting the systems username

Bruce,

Try something like

Declare Function GetUserName Lib "advapi32.dll" Alias
"GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

Function LogonName() As String
Dim S As String: S = String$(255, " ")
Dim L As Long: L = Len(S)
If GetUserName(S, L) Then
LogonName = Left(S, L - 1)
End If
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Bruce A. Perry" wrote in message
...
Does anyone know how threw VBA to get the systems username
or login name. I can get the Application.UserName, but it
might not be the same for someone loging in at a diffrent
location?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Getting the systems username

Try -

' Obtain the NT login id and use it as the user name in MS
Excel.
Application.UserName = Environ("USERNAME")


-----Original Message-----
Bruce,

Try something like

Declare Function GetUserName Lib "advapi32.dll" Alias
"GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

Function LogonName() As String
Dim S As String: S = String$(255, " ")
Dim L As Long: L = Len(S)
If GetUserName(S, L) Then
LogonName = Left(S, L - 1)
End If
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Bruce A. Perry" wrote in message
...
Does anyone know how threw VBA to get the systems

username
or login name. I can get the Application.UserName, but

it
might not be the same for someone loging in at a

diffrent
location?



.

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
HOW TO GET TRACKING SYSTEMS [email protected] Excel Worksheet Functions 0 May 15th 08 12:49 PM
Solve nonlinear systems of equations? Eck Excel Discussion (Misc queries) 1 April 14th 07 01:05 PM
Ensure column width is adequate across systems RBeau Excel Discussion (Misc queries) 1 April 27th 06 10:19 PM
Scatterplot chart area changes size on different systems Hubris00 Charts and Charting in Excel 1 October 27th 05 09:32 PM
Information Systems Manager ljohn21752 Excel Discussion (Misc queries) 1 August 11th 05 11:51 PM


All times are GMT +1. The time now is 06:41 AM.

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

About Us

"It's about Microsoft Excel"