Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default 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



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
Cell locking based on domain user Wolter Excel Worksheet Functions 6 June 4th 09 06:42 AM
How to separate user name and domain name in email id? Harshad[_2_] Excel Discussion (Misc queries) 4 February 17th 09 11:34 AM
2007 Converter wont work as domain user RobGrim Excel Discussion (Misc queries) 0 October 15th 08 11:30 AM


All times are GMT +1. The time now is 03:56 PM.

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"