ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Identify computer Login ID (https://www.excelbanter.com/excel-programming/418570-identify-computer-login-id.html)

SJW_OST[_2_]

Identify computer Login ID
 
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

Barb Reinhardt

Identify computer Login ID
 
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

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"SJW_OST" wrote:

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


SJW_OST[_2_]

Identify computer Login ID
 
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

"Barb Reinhardt" wrote:

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

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"SJW_OST" wrote:

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


Gord Dibben

Identify computer Login ID
 
Application.Username is just the name typed into

ToolsOptionsGeneralUsername

Environ("Username") is the login name.


Gord Dibben MS Excel MVP

On Wed, 15 Oct 2008 17:06:02 -0700, SJW_OST
wrote:

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

"Barb Reinhardt" wrote:

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

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"SJW_OST" wrote:

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




All times are GMT +1. The time now is 09:13 PM.

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