Identify computer Login ID

  • Thread starter Thread starter SJW_OST
  • Start date Start date
S

SJW_OST

I am looking for a way to have Excel identify and record the ID used to log
onto the computer as a way of identifying who has accessed/opened the Excel
file. So if I open the Excel file, I want the workbook to record my computer
Login ID on a sheet in cell A1. Then if my coworker opens the file I want
their ID to be recorded under mine in cell A2, the next coworker in cell A3
and so forth.
I found a way to do this operation in Access but now I need the same thing
in Excel.

Any help is greatly appreciated!
Stephen W
 
Try this

Sub test()
Dim myUserName As String
Dim objNetwork As Object
Set objNetwork = CreateObject("Wscript.network")
myUserName = objNetwork.UserName
Debug.Print myUserName
End Sub

There may be another way, but it works
 
Your code works great.
I found this code that works as well.

Sub CaptureUserID()
'2 cells must be filled in for this. Enter a character in cell A1 & A2.

Dim rng As Range

Set rng = Sheets("Sheet3").Range("A1").End(xlDown).Offset(1, 0)

rng.Value = Now()
rng.Offset(0, 1) = Application.UserName
ActiveWorkbook.Save
End Sub

Thanks for all of your help!
Stephen W
 
Application.Username is just the name typed into

Tools>Options>General>Username

Environ("Username") is the login name.


Gord Dibben MS Excel MVP
 
Back
Top