View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default Identify User, Copy/Paste Login Info. to File on C:\

Very, very cool site. Thanks!!

I went with this, module code, not sheet code:
Private Sub Auto_Open()

LogInformation ThisWorkbook.Name & " opened by " & _
Application.UserName & " " & Format(Date, "yyyy-mm-dd") & " " &
Format(Time, "hh:mm")

End Sub

Sub LogInformation(LogMessage As String)
Const LogFileName As String = "C:\MyLog.txt"
Dim FileNum As Integer
FileNum = FreeFile ' next file number
Open LogFileName For Append As #FileNum ' creates the file if it doesn't
exist
Print #FileNum, LogMessage ' write information at the end of the text file
Close #FileNum ' close the file
End Sub

Regards,
Ryan---


--
RyGuy


"JP" wrote:

One way:

I have a routine that can write whatever you want to an external (csv)
file. Look for "Spreadsheet Logging to CSV file" he

http://codeforexcelandoutlook.com/excel.html


HTH,
JP


On Apr 1, 2:02 pm, ryguy7272
wrote:
I originally posted this a few days ago and got only one response, which
although helpful, didn't allow me to do what I was hoping to do. I'm
wondering if there is a way to create a private sub to identify someone who
has opened a spreadsheet, by the windows login ID, and also get the time and
date that the spreadsheet was opened. I'd like to copy/paste this information
to a Word document (or a text file), which could be located on the C-drive.
Ideally, I'd like to create a running log of all instances of users opening
the spreadsheet, so the 2nd, 3rd, 4th, etc. users would have to be appended
to the Word document so that the original time stamps were not overwritten.