View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Loging users who open a file

A simple text file should be OK, call this in the open event

Sub test()
Dim sFile As String
Dim sText
Dim ff As Long

sFile = Application.DefaultFilePath
' or maybe
'sFile = ThisWorkbook.Path
If Right$(sFile, 1) < "\" Then sFile = sFile & "\"

sFile = sFile & "logTest.txt"

sText = "ABC" & vbTab & Format(Now, "yyyy-mm-dd hh:mm:ss")

ff = FreeFile
Open sFile For Append As #ff
Print #ff, sText
Close #ff

End Sub

I don't know what fOSUserName() is but replace the "ABC" with it.

Regards,
Peter T


"PJFry" wrote in message
...
I like to log the users who open spreadsheets that I have developed. What
I
have done in the past is to run the code below to record the information
that
I need.

Dim Log As Range

'Set the range for the user log
Set Log = Sheet6.Range("A2")

'Find the first empty cell
Do Until IsEmpty(Log)
Set Log = Log.Offset(1, 0)
Loop

'Record user name and time opened
ActiveCell.Value = fOSUserName()
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Now()

'Save the changes
ActiveWorkbook.Save


The workbooks I have typically developed are summary in nature and do not
take up much more than half a meg. This process would run and there would
a
very small delay and the user didn't know there was anything happening.
(The
fact that I capture this data is common knowlege though.)

We just upgraded to Excel 2007 and I have started to develop larger
workbooks that I want to track. The lag is enough that it will start to
cause problems.

Is there a better way to do this? Can I write to an un-opened book or a
text-file?
I am open to any suggestions.

Thanks!
PJ