+ Reply to Thread
Results 1 to 3 of 3

Pop Up Box that recognises the Windows User Logged On

Hybrid View

  1. #1
    Registered User
    Join Date
    08-19-2009
    Location
    Southampton, UK
    MS-Off Ver
    Excel 2003
    Posts
    6

    Pop Up Box that recognises the Windows User Logged On

    Can I get a pop up box that incorporates the windows logged on user? It would need to recognise the individual windows log on ID's?

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Pop Up Box that recognises the Windows User Logged On

    Yes,

    try this..

    MsgBox (Environ("UserName"))
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Pop Up Box that recognises the Windows User Logged On

    Try one of these User Defined Functions:

    Using Regular Excel VBA

    Function NetworkUserName() As String
       NetworkUserName = Environ("Username")
    End Function

    Using the windows API

    Declare Function apiGetUserName _
    Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, _
    nSize As Long) As Long
    Then use this API function call in your own function
    Function GetUserName() As String
        Application.Volatile
        Dim sBuff As String * 25
        Dim lBuffLen As Long
        
        lBuffLen = 25
        apiGetUserName sBuff, lBuffLen
        GetUserName = Left(sBuff, lBuffLen - 1)
    End Function
    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1