ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to retrieve domain user name in macro (https://www.excelbanter.com/excel-programming/274079-how-retrieve-domain-user-name-macro.html)

terence

How to retrieve domain user name in macro
 
Hi,

I would like to make my macro to retrieve the current NT
domain user login ID. Does anyone know how to code?
Thanks a lot.

Terence

Bob Phillips[_5_]

How to retrieve domain user name in macro
 
Terence,

Here is a function to do it

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

Public Function UserName() As String
Dim sName As String * 256
Dim cChars As Long
cChars = 256
If GetUserName(sName, cChars) Then
UserName = Left$(sName, cChars - 1)
End If
End Function


--

HTH

Bob Phillips

"Terence" wrote in message
...
Hi,

I would like to make my macro to retrieve the current NT
domain user login ID. Does anyone know how to code?
Thanks a lot.

Terence





All times are GMT +1. The time now is 02:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com