Logging activity

  • Thread starter Thread starter George Foreman
  • Start date Start date
G

George Foreman

People will use my spreadsheet at work on a network
drive. If someone uses the sheet can I log their windows
xp pro username and the date and time in a hidden sheet
for me to review?

Maybe a step further is to log all keystrokes A-Z and 0-9
for any entrys in the past 48 hours! This would
eliminate the file from going huge as there would only
ever be in 48 hours around 1000 words or numbers ever
entered.

Hope you can give me some help on this one :->

Regards and thanks in advance
 
Here is the user name code...

Option Explicit


'-----------------------------------------------------------------------------------------------------
' This module only provides the username.
'=====================================================================================================


Public Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long


Public Function ReturnNTUserName() As String

' Returns the NT Domain User Name

Dim rString As String * 255, sLen As Long, tString As String
Dim NWUserName As String

tString = ""

On Error Resume Next
sLen = GetUserName(rString, 255)
sLen = InStr(1, rString, Chr(0))
If sLen > 0 Then
tString = Left(rString, sLen - 1)
Else
tString = rString
End If
On Error GoTo 0

NWUserName = Left(Right(tString, Len(tString) - 1), Len(tString) - 2)
ReturnNTUserName = UCase(Left(tString, 1)) + NWUserName +
Right(UCase(tString), 1)

End Function

As for logging in a hidden sheet, that will work but you might be better off
with a database such as access than the hidden sheet. Saves the whole problem
with purging. Also if you end up with more than 1 copy of the spread sheet
you will have to check 2 different sheets in 2 different files... One access
database would be my preference. I have code for an ODBC Connection. You can
just use the on open and on close events to track entry and exit from the
sheet...

HTH
 
George,

Another way to insert the username:

Worksheets("Sheet1").Range("A1") = Application.UserName

hth,

Doug Glancy
 
That will give you their user name as defined by Excel, not their windows
login name. It may or may not work for you depending on what you want but it
will in all likelyhood vary from their windows login name...
 
Thanks Jim.

Doug

Jim Thomlinson said:
That will give you their user name as defined by Excel, not their windows
login name. It may or may not work for you depending on what you want but it
will in all likelyhood vary from their windows login name...
 
Unfortunately the username as defined by excel
is "Company Name" and says they already have the file in
use not individual which I need. Is there a way I can
find this out??

based on the windows xp login username?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top