Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Pedro Gilbert   on Dec 31 In MS Office Category.

  
Question Answered By: Marina Smith   on Dec 31

See if this gets you what you need: paste the following new function into a VB
module:

Option Explicit
'api call for obtaining the username
Private Declare Function GetUserName& Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long)

Public Function WindowsUserName() As String
Dim szBuffer As String * 100
Dim lBufferLen As Long
lBufferLen = 100
If CBool(GetUserName(szBuffer, lBufferLen)) Then
WindowsUserName = Left$(szBuffer, lBufferLen - 1)
Else
WindowsUserName = CStr(Empty)
End If
End Function


The above new function returns the username by entering the new function into a
cell:
say cell  B2=WindowsUserName( )
I found this cool one at vbaexpress.com

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Capture users ID when they open a spreadsheet Or get search suggestion and latest updates.


Tagged: